C++ 5 lines O(1) space complexity but at the cost of time


#1
int i=1, j=A.size();
while(i<j){
    auto it = find(A.begin(), A.begin()+i, A[i]);
    if(it != (A.begin()+i)) *it +=1;
    i++;
}
return A;