Problem of the day
1. If ‘K’ is not present in the array, then the first and the last occurrence will be -1.
2. ARR may contain duplicate elements.
The first line of input contains an integer 'T' which denotes the number of test cases or queries to be run. Then the test cases follow.
The first line of each test case contains two single-space separated integers ‘N’ and ‘K’, respectively.
The second line of each test case contains ‘N’ single space-separated integers denoting the elements of the array/list ARR.
Return two single-space separated integers denoting the first and the last occurrence of ‘K’ in ARR, respectively.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= N <= 5000
0 <= K <= 10^5
0 <= ARR[i] <=10^5
Time Limit : 1 second
2
6 3
0 5 5 6 6 6
8 2
0 0 1 1 2 2 2 2
-1 -1
4 7
For the first test case, 3 is not present in the array. Hence the first and last occurrence of 3 is -1 and -1.
For the second test case, the first occurrence of 2 in at index 4 and last occurrence is at index 7.
2
4 0
0 0 0 0
1 2
2
0 3
0 0