#K55607. Longest Unique Contiguous Subarray
Longest Unique Contiguous Subarray
Longest Unique Contiguous Subarray
You are given an array of integers. Your task is to determine the length of the longest contiguous subarray that contains only unique elements (i.e. no duplicates).
In other words, if you denote the array as \(a_1, a_2, \ldots, a_n\), find the maximum \(L\) such that there exists an index \(i\) with the subarray \(a_i, a_{i+1}, \dots, a_{i+L-1}\) having all distinct elements.
For example, given the array [1, 2, 3, 1, 2, 3, 4, 5], the longest subarray with all unique elements is [1, 2, 3, 4, 5] with length 5.
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers representing the elements of the array.
outputFormat
Output a single integer on standard output (stdout) representing the length of the longest contiguous subarray that contains only unique elements.
## sample8
1 2 3 1 2 3 4 5
5