last-substring-in-lexicographical-order

last-substring-in-lexicographical-order


给你一个字符串 s ,找出它的所有子串并按字典序排列,返回排在最后的那个子串。



 



示例 1:



输入:s = "abab"
输出:"bab"
解释:我们可以找出 7 个子串 ["a", "ab", "aba", "abab", "b", "ba", "bab"]。按字典序排在最后的子串是 "bab"。


示例 2:



输入:s = "leetcode"
输出:"tcode"


 



提示:




  • 1 <= s.length <= 4 * 105

  • s 仅含有小写英文字符。


Report Page