Bob has an array \(A\) of size \(N\), and he is very fond of two integers \(X\) and \(Y\). Find the length of the longest subarray, such that it contains exactly \(X\) distinct integers and \(Y\) exist at least once in the subarray.
Input format
- The first line contains an integer \(T\), which denotes the number of test cases.
- The first line of each test case contains three space separated integers \(N\), \(X\), \(Y\) denoting the size of array \(A\), the value of \(X\) and \(Y\), respectively.
- The second line of each test case contains \(N\) space-separated integers, denoting the elements of array \(A\).
Output format
For each test case, print the length of the largest subarray, such that it contains exactly \(X\) distinct integers and \(Y\) exist at least once in the subarray in a new line.
Constraints
For test case \(1\): There exists only one subarray having exactly 2 distinct elements and having at least one occurrence of \(1\), i.e. \([3,1]\) of length \(2\). Therefore, the answer will be \(2\).
For test case \(2\): \(2\) is not present in the whole array \(A\). So, the answer is \(0\).
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor