#1163
Last Substring in Lexicographical Order
master · 1895 · lc hard +32 · verified · 35% accepted · 664 likes · top 13%
Description
Given a string s, find and return the lexicographically largest among all of its substrings.
Example 1:
Input: s = "abab"
Output: "bab"
Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab".
Example 2:
Input: s = "leetcode"
Output: "tcode"
Code
1
2
3