Given an array of integers, find the maximum length of a contiguous subarray in which every value appears at most once.
7 1 2 1 3 4 3 5
The longest segment without repeated values is 2 1 3 4, with length 4.
4
5 9 9 9 9 9
Any valid segment can contain only one value, so the answer is 1.
1
6 -1 0 -1 2 3 4
The segment 0 -1 2 3 4 has all distinct values and length 5.
5