Remove duplicate

The ouputs are correct for many test cases.
but when we insert ‘helloworld’ output should be (helowrd) but it is giving wrong output.

Hey @juyal.sid
For helloworld
output should be heloworld because we only have to remove consecutive duplicates
Correction is on line 16

   if(a[c]!=a[c-1])//initially a[c]!=a[b]

can you please send the code for removing all duplicates.

For that u have to mantain another array (kind of hashmap ) and I am not sure if u have learnt it yet or not
You can also solve it by using 2 loops

yeah pls send the two loops method code.


Here check this

Hey @juyal.sid
Is ur doubt resolved ?

in this it is showing helowrdld as output.

INPUT:helloworld 1 1

Its not even working on my side for that input
Also you are prinitn till length that is why u must be getting that
only do cout<<str and it will give u correct output

okay thank you. i got it

1 Like

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.