Given a sorted array with possibly duplicate elements. The task is to find indexes of first and last occurrences of an element X in the given array.
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N denoting the size of the array. Then in the next line are N space separated values of the array. The last line of each test case contains an integer X.
For each test case in a new line print two integers separated by space denoting the first and last occurrence of the element X. If the element is not present in the array print -1.
1 <= T <= 100
1 <= N <= 1000
1 <= A, X <= 1018
1 3 5 5 5 5 67 123 125
1 3 5 5 5 5 7 123 125
Testcase 1: Index of first occurrence of 5 is 2 and index of last occurrence of 5 is 5.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.