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

后端 未结 14 814
故里飘歌
故里飘歌 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条回答
  •  一生所求
    2020-12-02 13:01

    Just figured this out myself and wrote some code for this (written in C#) with a lot of comments. Hope this helps someone:

    // Check whether the string contains a repeating sequence.
    public static bool ContainsRepeatingSequence(string str)
    {
        if (string.IsNullOrEmpty(str)) return false;
    
        for (int i=0; i

    Feel free to ask any questions if it's unclear why it works.

提交回复
热议问题