The Strongest String - 1
Practice
3.6 (36 votes)
Ad Hoc
Approved
Data structures
Easy
Implementation
Open
Problem
78% Success 13049 Attempts 20 Points 1s Time Limit 64MB Memory 1024 KB Max Code

Maga and Alex are good at string manipulation problems. Just now they have faced a problem related to string. But it is not a standard string problem. They have no idea to solve it. They need your help.

A string is called unique if all characters of string are distinct.

String \(s_1\) is called subsequence of string \(s_2\) if \(s_1\) can be produced from \(s_2\) by removing some characters of \(s_2\).

String \(s_1\) is stronger than \(s_2\) if \(s_1\) is lexicographically greater than \(s_2\).

You are given a string. Your task is to find the strongest unique string which is subsequence of given string.

Input:

first line contains length of string.
second line contains the string.

Output:

Output the strongest unique string which is subsequence of given string.

Constraints:

\(1 \le |S| \le 100000\)

All letters are lowercase English letters.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
45 votes
Tags:
Ad-HocApprovedEasyOpen
Points:20
642 votes
Tags:
Ad-HocEasyOpenString Manipulation
Points:20
16 votes
Tags:
AlgorithmsEasyString Manipulation