#K76837. Remove Duplicates and Sort Characters

    ID: 34731 Type: Default 1000ms 256MiB

Remove Duplicates and Sort Characters

Remove Duplicates and Sort Characters

You are given a string \( S \) that consists only of lowercase English letters. Your task is to remove all duplicate characters from \( S \) and output a new string where the remaining characters are sorted in increasing order.

Constraints:

  • \( 1 \leq |S| \leq 10^5 \)
  • \( S \) contains only lowercase English letters.

Expected Time Complexity: \( O(N\log N) \) and Auxiliary Space: \( O(N) \).

Example:

Input: banana
Output: abn

inputFormat

The input consists of a single line containing the string ( S ). The string contains only lowercase English letters.

outputFormat

Output a single string that contains the unique characters of ( S ) in sorted order.## sample

banana
abn