#C3506. Remove Duplicate Characters
Remove Duplicate Characters
Remove Duplicate Characters
You are given a string s
consisting of lowercase letters. Your task is to remove duplicate characters from the string while maintaining the order of their first occurrence.
For example, if s = "programming"
, then the output should be "progamin"
because the first occurrence of each character is preserved and duplicates are removed.
This is a typical problem that tests your ability to process strings and use data structures to track seen characters.
Input constraints: The input string may be empty or contain up to 105 characters.
inputFormat
The input is read from standard input (stdin). It consists of a single line containing a string s
of lowercase letters.
outputFormat
The output should be printed to standard output (stdout) as a single line string after removing duplicate characters while maintaining the order of their first occurrence.
## sampleprogramming
progamin