Need another method

i need to slove with any other method because im not getting this one.

@kumarankit3450 you can do this:
create another string/char-array, put first element into it
then have a pointer at 1(let x=1)
now just ignore all elements which are repeating, this can be checked by
while(x<n and arr[x]==arr[x-1])
x++;
this loop exits either when x=n(reached end) or when a new character comes.
so this is final pseudo code:
x=0
y=0
while(x<n){
ans[y]=arr[x]
x++
y++
while(x<n and arr[x]==arr[x-1])
x++;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.