Lexicographically largest substring of a string

Revision en1, by Mikemirzyanov1, 2020-04-13 15:26:22

Hi can someone share the approach to find lexicographically largest substring in a string?

I know the answer will always be one of the suffixes but cannot find a way to analyze those suffixes efficiently.

Constraints |S| < 1e5

I need an O(n) approach or O(nlogn) without suffix array.

Any ideas are welcome.

[Solution](https://leetcode.com/problems/last-substring-in-lexicographical-order/discuss/363662/Short-python-code-O(n)-time-and-O(1)-space-with-proof-and-visualization)

I found this link on Leetcode but cannot understand it.

Tags #substrings

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Mikemirzyanov1 2020-04-13 15:26:22 597 Initial revision (published)