#228. 字符串相邻字符去重
字符串相邻字符去重
Remove Adjacent Duplicates
Background
Congcong has been organizing his text files recently. He noticed that many texts contain consecutive duplicate characters, which makes the files look messy. To make the text cleaner, he decided to write a program that automatically removes all adjacent duplicate characters, keeping only one instance.
Problem Description
Given a string, recursively return a "cleaned" string where adjacent characters that are the same have been reduced to a single character. For example, "yyzzza" yields "yza".
Input Format
The input is given from standard input in the following format.
s
Output Format
The output is printed to standard output in the following format.
cleaned_s
Sample
yyzzza
yza
abbbcdd
abcd
Hello
Helo
Sample Explanation
For the first sample "yyzzza\