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

后端 未结 14 824
故里飘歌
故里飘歌 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:07

    First write a method that find repeating substring sub in the container string as below.

    boolean findSubRepeating(String sub, String container);
    

    Now keep calling this method with increasing substring in the container, first try 1 character substring, then 2 characters, etc going upto container.length/2.

提交回复
热议问题