Longest Distinct Stretch
Find the longest contiguous subarray in which all values are distinct.
Input: the first line has N; the second line has N integers.
Output: the maximum length of a duplicate-free window.
Constraints:
- 1 ≤ N ≤ 105
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
7 1 2 3 1 2 4 5
Output 1
5
Input 2
3 7 7 7
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.