Search
 
SCRIPT & CODE EXAMPLE
 

CPP

sort 0 1 2 leetcode

/* Dutch National flag algorithm  --  IN-PLACE */
        int low = 0 ,  mid = 0  , high = nums.size()-1 ; 
        while (mid <= high) {
            if (nums[mid] == 0) {
                swap(nums[low] , nums[mid]) ; 
                mid++ ; low++ ; 
            }
            else if (nums[mid] == 1) {
                mid++ ;
            }
            else {
                swap(nums[mid] , nums[high]) ; 
                high-- ; 
            }
        }
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to get the size of a vector in c++ 
Cpp :: time_t to int 
Cpp :: Quicksort taking random pivot 
Cpp :: calloc c++ 
Cpp :: upcasting in c++ 
Cpp :: convert decimal to binary in c++ 
Cpp :: detect end of user input cpp 
Cpp :: cin.getline 
Cpp :: how to initialize array with new in c++ 
Cpp :: 2d array c++ 
Cpp :: c++ hello world 
Cpp :: concat two vectors c++ 
Cpp :: c++ lambda 
Cpp :: stack implementation using class in c++ 
Cpp :: min in c++ 
Cpp :: C++ Vector Operation Add Element 
Cpp :: c++ hashmaps 
Cpp :: image shapes in opencv c++ 
Cpp :: unordered_set to vector 
Cpp :: string search c++ 
Cpp :: cpp while 
Cpp :: how can we create 4 digit random number in c++ 
Cpp :: input n space separated integers in c++ 
Cpp :: insert in vector 
Cpp :: c++ access second last element of vector 
Cpp :: c++ check if debug or release visual studio 
Cpp :: inheritance in c++ 
Cpp :: passing custom function in sort cpp 
Cpp :: how to input in cpp 
Cpp :: fill two dimensional array c++ 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =