All Tracks Algorithms String Algorithms Basics of String Manipulation Problem

The Strongest String - 1
Tag(s):

Ad-Hoc, Data Structures, Easy, Implementation

Problem
Editorial
Analytics

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.

SAMPLE INPUT
5
abvzx
SAMPLE OUTPUT
zx
Explanation

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

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 64 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Challenge Name

GSF Hacks

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?