#C6286. Longest Distinct Subarray
Longest Distinct Subarray
Longest Distinct Subarray
You are given a sequence of integers. Your task is to find the length of the longest contiguous subarray that contains only distinct numbers.
The subarray is defined as a consecutive segment of the array. For example, in the array [1, 2, 1, 3, 4], the longest subarray with all distinct numbers is [2, 1, 3, 4] which has a length of 4.
Input: The first line of input contains an integer N representing the number of elements. The second line contains N space-separated integers.
Output: Output a single integer, the length of the longest subarray with all distinct elements.
inputFormat
The input is given via standard input (stdin) and consists of two lines. The first line contains an integer N, the number of elements in the array. The second line contains N space separated integers.
outputFormat
Print a single integer to standard output (stdout) representing the length of the longest contiguous subarray with all distinct numbers.
## sample5
1 2 1 3 4
4