#C13872. Remove Odd Occurrence Characters
Remove Odd Occurrence Characters
Remove Odd Occurrence Characters
You are given a string s
. Your task is to remove all characters that appear an odd number of times in the string, while retaining the order of the remaining characters. In other words, if a character appears an even number of times in the string, it should be kept (all of its occurrences), and if it appears an odd number of times, it should be removed entirely.
Note: Please use LaTeX format for any mathematical formulas. For instance, you may denote counts as $\text{count}(c)$ for a character $c$.
Example:
- Input:
aabbcc
→ Each character appears twice (an even number), so the output isaabbcc
. - Input:
abc
→ Each character appears once (an odd number), so the output is an empty string. - Input:
aabbccdde
→ The charactere
appears once and is removed, resulting inaabbccdd
.
inputFormat
The input consists of a single line containing a non-empty string s
which may include letters, digits, punctuation marks, and special characters.
The input is provided via standard input (stdin).
outputFormat
Output a single line containing the modified string where all characters that appear an odd number of times in the input have been removed. The output should be written to standard output (stdout).
## sampleaabbcc
aabbcc