← 返回 oracle 的题目列表Lexicographically Maximum Substring
类型:online_judge
Given a string s consisting only of lowercase English letters, return its lexicographically largest non-empty contiguous substring.
Strings are compared using standard lexicographic order: compare the first differing character; if one string is a prefix of another, the longer string is larger.
Input
s
Output
the lexicographically largest non-empty substring
Constraints
1 <= len(s) <= 2 * 10^5
s contains only characters from a to z.
Examples
Input: abab
Output: bab
Input: leetcode
Output: tcode
Example
Input
abab
Output
bab