75. Sort Colors Posted on 2020-10-06 | Edited on 2021-01-22 | Views: LeetCode 1234567891011121314151617181920class Solution { public void sortColors(int[] nums) { int p0=0,curr=0,p2=nums.length-1; while(curr<=p2){ if(nums[curr]==0){ nums[curr]=nums[p0]; nums[p0]=0; curr++;p0++; } else if(nums[curr]==2){ nums[curr]=nums[p2]; nums[p2]=2; p2--; } else{ curr++; } } }}