I am not proficient in algorithm design but was asked this question in one of the job interview. My solution was naive one with heavy complexity but can this be done in shorter time.
Given an array of integers find all the sub sequence of that array which repeats in array. Print sub sequence and then start index and end end index of all their occurrence.
e.g 1,0,1,9,5,1,9,5,1
Here it should print
1,9,5
3:5 6:8
9,5,1
4:6 7:9
1,9
3:4 6:7
5,1
5:6 8:9
9,5
4:5 7:8
My solution was to start from Arr[0] till Arr[N/2 -1] and check if it repeats then do reduced end index by 1 and keep on checking if it repeats.
Thanks
1is repeated several times in your sample array, but is absent in your sample output (it is definitely sub-sequence and it is repeated).