#K57472. Longest Distinct Contiguous Subsequence Length

    ID: 30428 Type: Default 1000ms 256MiB

Longest Distinct Contiguous Subsequence Length

Longest Distinct Contiguous Subsequence Length

You are given a list of n integers, representing runes. Your task is to find the length of the longest contiguous subsequence that contains all distinct elements. In other words, you need to determine the maximum number of consecutive integers in the array such that no integer appears more than once.

This problem can be approached using the sliding window technique. For each window considered, ensure that all elements are unique. The answer is the maximum window size found which satisfies this condition.

Formally, if we denote the input list by \(a_1, a_2, \dots, a_n\), find the maximum \(k\) such that there exists an index \(i\) with \(1 \le i \le n-k+1\) where the elements \(a_i, a_{i+1}, \dots, a_{i+k-1}\) are all distinct.

inputFormat

The first line of input contains a single integer n, the number of runes.

The second line contains n space-separated integers representing the runes.

outputFormat

Output a single integer which is the length of the longest contiguous subsequence with all distinct elements.

## sample
7
1 2 3 2 4 5 6
5

</p>