Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- **/
- class Solution {
- public:
- void sortColors(vector<int>& nums)
- {
- int low = 0;
- int high=nums.size()-1;
- int i=0;
- while(i<= high)
- {
- if(nums[i]==0){
- swap(nums[i] , nums[low]);
- i++;low++;continue;
- }
- if(nums[i]==2)
- {
- swap(nums[i] , nums[high--]);continue;
- }
- i++;
- }
- }
- };
Add Comment
Please, Sign In to add comment