#C13399. Remove Duplicate Characters
Remove Duplicate Characters
Remove Duplicate Characters
Given an input string s
, remove the duplicate characters while preserving the order of their first appearance. The removal is case-sensitive, meaning that uppercase and lowercase letters are considered different characters.
For example, if s = "programming"
, the output should be "progamin"
because the first occurrence of each character is retained, and subsequent duplicates are removed.
This problem can be formally described as follows:
Let \(s = s_0 s_1 \cdots s_{n-1}\) be a string of length \(n\). Your task is to construct a new string \(t\) by processing \(s\) from left-to-right and appending each character \(s_i\) to \(t\) if and only if \(s_i\) has not appeared before in \(t\). Output the resulting string \(t\).
inputFormat
The input consists of a single line that contains the string s
. The string may contain letters, digits, and symbols. It is read from standard input (stdin).
outputFormat
Output the string after removing duplicate characters, preserving the order of their first occurrence. Write the result to standard output (stdout).
## sampleprogramming
progamin