Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Last Substring In Lexicographical Order
HARD
45 mins
3 upvotes
Strings
Topics (Covered in this problem)
Problem solved
Badge
Skill meter
Strings
-
-
Other topics
Problem solved
Badge
Skill meter
Matrices (2D Arrays)
-
-
Linked List
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Last Substring In Lexicographical Order

Contributed by
Arshit Babariya
Hard
yellow-spark
0/120
Avg time to solve 45 mins
Success Rate 55 %
Share
3 upvotes

Problem Statement

You are given a string ‘Str’ of length ‘N’. Find the last substring of ‘Str’ in lexicographical order.

In Lexicographical order string ‘S1’ comes before string ‘S2’ if S1 is the prefix of S2 and (|S1| < |S2|), or if none of them is a prefix of the other and at the first position where they differ, the character in ‘S1’ is smaller than the character in ‘S2’.

Example :
Consider string ‘Str’ = “abba”, then its substring in lexicographical order is [“a”, “ab”, “abb”, “abba”, “b”, “bb”, “bba”].  Clearly, the last substring in lexicographical order is  “bba”. 
Detailed explanation ( Input/output format, Notes, Constraints, Images )
Reset Code
Full screen
Auto
copy-code
Console