The Strongest String - 1

3.6

36 votes
Ad-Hoc, Approved, Data Structures, Easy, Implementation, Open
Problem

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 is called subsequence of string if can be produced from by removing some characters of .

String is stronger than if is lexicographically greater than .

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:

All letters are lowercase English letters.

Sample Input
5
abvzx
Sample Output
zx
Time Limit: 1
Memory Limit: 64
Source Limit:
Explanation

Select all subsequence of the string and sort them in ascending order. The greatest of all is zx.

Contributers:
Editor Image

?