Is there a O(1) solution.
Approach :
public void removeDuplicates(char[] a, int n){
for(int i = 0; i < n; i++){
for(int j = 0; j < n;){
if(a[i] == a[j])
a[j] = s [--n];
else j++;
}
}
s[i] = '\0';
}
But the time complexity is O(n^2). Can it be optimised further ?