#C13954. Unique Character Sequence

    ID: 43549 Type: Default 1000ms 256MiB

Unique Character Sequence

Unique Character Sequence

Given a string s, return a new string that contains only the unique characters from s in the order that they first appear. The function should be case-sensitive and preserve all whitespace and punctuation marks.

Note: The order of characters in the resulting string must be the same as their first occurrence in the input string.

For example:

  • If s = "apple", then the output should be "aple".
  • If s = "banana", then the output should be "ban".
  • If s = "hello!", then the output should be "helo!".

The mathematical description: Let \( s = s_1s_2\ldots s_n \) be a string. Define a sequence \( t \) such that for each \( s_i \) if \( s_i \notin \{ s_1,s_2,\ldots,s_{i-1} \} \) then append \( s_i \) to \( t \). Output the string concatenation of all characters in \( t \).

inputFormat

The input consists of a single line containing the string s. The string can include letters, digits, punctuation, and whitespace characters. Do note that the string may be empty.

Input is provided through standard input (stdin).

outputFormat

Output a single line containing the string that results from removing duplicate characters from the input string, preserving only the first occurrence of each character. The output is printed to standard output (stdout).

## sample
apple
aple