Problem of the day
For a given string, "aaaAAbbcccbd"
The new string formed after removing the consecutive duplicates characters will be, "aAbcbd".
The first and the only line of input contains a string 'STR' with no space in between the characters.
Print the final string after removing all the consecutive duplicates.
You don't have to print anything, it has already been taken care of. Just implement the given function.
1 <= |S| <= 10^5
Where |S| represents the length of the string.
Time limit: 1 sec
aabccba
abcba
The string basically is a concatenation of [aa][b][cc][b][a] without considering the brackets. From each segment we need to choose only 1 character as all the characters are duplicates, therefore the final answer is [a][b][c][b][a] = abcba
xxxyyyzwwzzz
xyzwz
The string basically is a concatenation of [xxx][yyy][z][ww][zzz]. After choosing 1 character from each segment our final answer is [x][y][z][w][z] = xyzwz