public class Solution {

public void sortColors(int[] nums) {

int oneCount = 0,twoCount=0;

int j =0;

for(int i=0;i<nums.length;i++){

if(nums[i]==0){

nums[j++]=0;

}

else if(nums[i]==1){

oneCount++;

}

else{

twoCount++;

}

}

while(oneCount>0){

nums[j++]=1;

oneCount--;

}

while(twoCount>0){

nums[j++]=2;

twoCount--;

}

```
}
```

}