Given an array of N integers that might contain duplicates, find the element whose last appearance is earliest.
First line of input contains a single integer T denoting the number of test cases. First line of every test case has one number N denoting the length of the array and second line of every test case has N integers.
For each test case, print the required output.
10 30 20 10 20
Below are indexes of last
appearances of all elements (0 based indexes)
10 last occurs at index 3
30 last occurs at index 1
20 last occurs at index 2
The element whose last appearance earliest
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.