I am trying to find a way to check if a list contains contiguous elements which are not duplicated.
For example,
A = [1, 1, 4, 2, 2, 2]
this list contains contiguous elements which are not duplicated.A = [1, 1, 4, 4, 3, 4, 7, 7, 7]
this list does not contains contiguous elements which are not duplicated. Here the value 4 is contiguous from index 2 and 3 but its occurs again at index 5 which is not acceptable.
Basically a unique value should only occur once in a list contiguously.
Is there any means where the time complexity should be less than O(n^2)
.
Also, is there some method in itertools
through which I could acheive this?