Given two arrays L and R consisting of N ranges of the form L and R, L[i] consists of starting point of range and R[i] consists of corresponding end point of the range. The task is to find the maximum occurred integer in all the ranges. If more than one such integer exits, print the smallest one.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the ranges. The next two lines contain the n space separated elements of L and R respectively.
Print the smallest maximum occured integer in all the ranges.
1 <= T <= 105
1 <= n <= 105
0 <= L[i], R[i] <= 105
1 4 3 1
15 8 5 4
1 5 9 13 21
15 8 12 20 30
Testcase 1: 4 is the most occuring element after considering all the ranges. So, output is 4.
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.