275. Last Substring in Lexicographical Order

HardStringString

Given a string s, return the last substring of s in lexicographical order (this is always the suffix starting at the position of the lexicographically largest rotation start).

Input: A quoted string s.

Output: Quoted string — the lexicographically last substring.

Examples

Example 1
Input: "abab"
Output: "bab"
Explanation: 'bab' is the largest suffix.
Example 2
Input: "leetcode"
Output: "tcode"
Explanation: Largest suffix.
Example 3
Input: "a"
Output: "a"
Explanation: Single char.

Constraints

Asked by

IBMMicrosoftAmazonGoogle
Solve this problem in the editor →