How to find repeating sequence of Integers in an array of Integers?

后端 未结 4 1250
清酒与你
清酒与你 2021-01-07 14:52

How to find repeating sequence of Integers in an array of Integers?

00 would be repeating, so would 123123, but 01234593623 would not be.

I have an idea to h

4条回答
  •  时光取名叫无心
    2021-01-07 15:10

    The answer posted by @AdrianLeonhard is perfectly working. But if I have a sequence of 0, 1, 2, 3, 4, 3, 5, 6, 4, 7, 8, 7, 8 many might be wondering on how to get all the repeated numbers from the array.

    So, I wrote this simple logic which prints all the repeated numbers with their positions

        int[] arr = {0, 1, 2, 3, 4, 3, 5, 6, 4, 7, 8, 7, 8};
    
        for(int i=0; i

提交回复
热议问题