Similar to quick sort lomuto partition algorithm


#1
public void sortColors(ArrayList<Integer> a) {
	    int n = a.size();
	    int i = -1, j = n;
	    int k = 0;
	    while(k < j){
	        if(a.get(k) == 0){
	            Collections.swap(a,++i,k++);
	        }
	        else if(a.get(k) == 1){
	            k++;
	        }
	        else{
	            Collections.swap(a,--j,k);
	        }
	    }
	}