#K58227. Remove Consecutive Duplicates
Remove Consecutive Duplicates
Remove Consecutive Duplicates
Given a string \(S\), your task is to remove all consecutive duplicate characters from \(S\) and output the resulting string.
For example, if \(S = \texttt{aaabbaaccd}\), the output should be \(\texttt{abacd}\). This problem requires you to process the string in a single pass, comparing adjacent characters, and ensuring that only the first character from any sequence of identical characters remains.
Note: The solution should be efficient and handle edge cases, such as when \(S\) is empty or contains only one character.
inputFormat
The input is provided via standard input (stdin) and consists of a single line containing the string \(S\) whose consecutive duplicate characters are to be removed.
outputFormat
The output should be printed to standard output (stdout) and consist of one line containing the processed string with consecutive duplicates removed.
## sampleaaabbaaccd
abacd