# Determine if all the continuous subsequences of an array contain at least one unique element in O(n lgn)

Given an array of length n, how to determine if all the continuous subsequence of this array contains at least one unique element.

Any subarray array[start, end] with 0 <= start <= end < n will have a unique element. The algorithm will return :

• True for array = [1, 3, 5, 3, 1]

• False for array = [1, 3, 5, 3, 5] because the sequence [3, 5, 3, 5] does not contain any unique element.

My idea (that does not seem to work in the competition) is to use divide and conquer as following :

• Create the following hash map : hash map[element] = [list of the index of the element in the array]
• Considering a recursive function that use start and end as array bounds
• Then iterating though the keys, and as soon as it finds, using the hash map, an element that is unique (only one index is in the range [start; end]), the index will be used as a pivot
• Recursively calling the function on array[start;pivot-1] and array[pivot+1; end]

As a subsequence can be the whole array, the array must contain one unique element. Then if each side of the pivot respect the condition, any subarray that contains the pivot obviously contain a unique element.

I simply want to know the my reasoning is valid. If yes, it means the problem comes from my code. Any thoughts ?