Problems > Keep First Occurrences

Keep First Occurrences

Difficulty: 900 2000 ms 128 MB

strings

Keep only the first occurrence of every character, preserving order, and print the result.

Input: one line with the string S.

Output: S with later duplicates removed.

Constraints:

  • 1 ≤ |S| ≤ 104
  • S contains lowercase English letters

Sample Tests

Input 1
banana
Output 1
ban
Input 2
abc
Output 2
abc

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.