#C6968. Eliminate Consecutive Duplicates
Eliminate Consecutive Duplicates
Eliminate Consecutive Duplicates
You are given a string s. Your task is to remove the minimum number of characters from s so that no two adjacent characters are the same. For example, if s = "aaabbccdde"
, the output should be "abcde"
.
In more formal terms, for a string (s) with length (n), you need to ensure that for every index (i) where (1 \leq i < n), the condition (s_i \neq s_{i+1}) holds after removal of some characters. The objective is to remove the minimum number of characters necessary to achieve this property.
Your solution should read input from stdin and write the result to stdout.
inputFormat
The input consists of a single line containing the string s. The string may be empty and its length can be up to (10^5) characters.
outputFormat
Output a single line containing the modified string where no two adjacent characters are the same.## sample
abcde
abcde