#C14091. Remove Duplicates and Count Removals
Remove Duplicates and Count Removals
Remove Duplicates and Count Removals
Given a string s
, remove duplicate characters while preserving the original order of appearance. In addition, print the count of the characters that were removed. Formally, if the resulting string after removal is t, then removed count = |s| - |t|.
For example, if s = "abracadabra"
, the first occurrence of each character (in order) gives abrcd
and the number of removed duplicate characters is 6
because 11 - 5 = 6.
The output should consist of two lines. The first line displays the count of removed characters in the format: Count of removed characters: X
. The second line displays the deduplicated string.
Note: The input is given via standard input (stdin) as a single line and the output should be printed to standard output (stdout).
inputFormat
The input consists of a single line containing the string s
. The string can be empty or consist of any printable characters.
outputFormat
Output two lines: The first line should be Count of removed characters: X
, where X
is the number of characters removed. The second line should be the deduplicated string.
abracadabra
Count of removed characters: 6
abrcd
</p>