1163.Last-Substring-in-Lexicographical-Order

1163. Last Substring in Lexicographical Order

题目地址

https://leetcode.com/problems/last-substring-in-lexicographical-order/

题目描述

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

Example 1:
Input: "abab"
Output: "bab"
Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab".

Example 2:
Input: "leetcode"
Output: "tcode"

Note:
1 <= s.length <= 4 * 10^5
s contains only lowercase English letters.

代码

Approach #1 Two Pointers + offset

Approach #2

Last updated

Was this helpful?