Mike and LMS
Practice
3.5 (12 votes)
Algorithms
Easy
Greedy algorithms
String manipulation
Sorting
Problem
80% Success 3603 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Disappointed and Disheartened Mike is really tired of jail life, and needs to take his mind off all this. Mike's roomate and good friend Kevin decidedes to help him, and tells him to try the following task:

Given a string S consisting of lowercase English alphabets of size N, can you find the lexicographically maximum substring of this string ? Mike has no knowledge what so ever of strings, and needs your help. Can you help Mike and improve his mood?

Input Format :

The first line contains a single integer N denoting the length of string S. The next line contains the string S.

Output Format :

Print the lexicographically maximum substring of String S on a single line.

Constraints :

\( 1 \le N \le 5000 \)

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
4 votes
Tags:
AlgorithmsEasyGreedy Algorithms
Points:20
17 votes
Tags:
Data StructuresEasyGreedy Algorithmsapproved
Points:50
54 votes
Tags:
ApprovedGreedy AlgorithmsMediumOpenTrees