STL for vectors will always remain your friend!


#1

I am sorry. I didn’t want to use much brain.

P.S. Please be thorough with all the STL expressions for vectors.

void Solution::sortColors(vector<int> &A) {
vector<int> B;
for(int j=0;j<3;++j){
    for(int i=0;i<A.size();++i){
        if(A[i]==j)
            B.push_back(j);
    }
}
A.clear();
B.swap(A);

}