String remove duplicates(3 test cases wrong)

Hi @Saksham12
Your code is failing those cases in which there are more than 2 consecutive because in the if case you can only comparing the current character to next character. So instead of this if you should use a while loop as follows :

while(ch[s]==ch[s+1])
s++;

In this way you will keep increasing s till the all consecutive duplicated are encountered.

1 Like