#K406. Remove Minimum Characters
Remove Minimum Characters
Remove Minimum Characters
Given a string s
, remove the minimum number of characters such that no three consecutive characters in the resulting string are identical. In other words, ensure that for every contiguous subsequence of three characters in the output, not all three characters are the same.
The order of characters must be preserved and only the necessary characters should be removed to satisfy the condition.
inputFormat
The input is provided via standard input (stdin) and consists of a single line containing the string s
.
outputFormat
Print the modified string to standard output (stdout) after removing the minimum number of characters such that no three consecutive characters are the same.
## sampleaaabaaa
aabaa