1163. Last Substring in Lexicographical Order
Hard
531
439

Given a string s, return the last substring of s in lexicographical order.

 

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"

 

Constraints:

  • 1 <= s.length <= 4 * 105
  • s contains only lowercase English letters.
Accepted
32K
Submissions
92K
Acceptance Rate
34.8%

Seen this question in a real interview before?
1/4
Yes
No

Discussion (0)

Related Topics
Copyright ©️ 2023 LeetCode All rights reserved