Minimum Lexicographic Rotation Using Suffix Array

后端 未结 3 1950
你的背包
你的背包 2021-01-06 10:08
    Consider a string of length n (1 <= n <= 100000). 
    Determine its minimum lexicographic rotation. 
    For example, the rotations of the string “alabala         


        
3条回答
  •  天涯浪人
    2021-01-06 10:39

    If you are using O(n log n) algorithm (sort by first letter, then by first two letters, then by first four, ...), you can make a little bit modified suffix array.

    Don't sort suffixes of string but it's cyclic rotations. It should be really small modification in the algorithm. A then you will get desired result directly.

    If you still want to use your method, then just take first index which is between 0 and N.

提交回复
热议问题