How to find repeating sequence of characters in a given array?

后端 未结 14 835
故里飘歌
故里飘歌 2020-12-02 12:42

My problem is to find the repeating sequence of characters in the given array. simply, to identify the pattern in which the characters are appearing.

          


        
14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 13:12

    Tongue-in-cheek O(NlogN) solution

    Perform an FFT on your string (treating characters as numeric values). Every peak in the resulting graph corresponds to a substring periodicity.

提交回复
热议问题