Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sort 0's 1's 2's
class Solution { public: void sortColors(vector<int>& nums) { int low=0; int mid=0; int high=nums.size()-1; while(mid<=high) { if(nums[mid]==0) { swap(nums[low],nums[mid]); low++; mid++; } else if(nums[mid]==1) { mid++; } else if(nums[mid]==2) { swap(nums[mid],nums[high]); high--; } } } };
run
|
edit
|
history
|
help
0
PreDir
TempQuickDoubly
InverseMatrix2n2
StackPat
anagram
sd5
Silly circular pointer
Addition of two matrix **Part 2
stack and queue
inheritance test