

If there are multiple conflicting meetings for a particular meeting. You can return any one of them.
Consider the matrix MEETINGS = [ [ 1, 3 ] , [ 4, 5 ] , [ 2, 5 ] ]
The array containing the Conflicting Meetings will be [ 3, 3, 1 ].
The first line of the input contains an integer 'T,’ denoting the number of test cases.
The first line of each test case contains an integer 'N', denoting the number of meetings.
The second line of each test case contains 'N' space-separated integers denoting the first column of the matrix 'MEETINGS'.
The third line of each test case contains 'N' space-separated integers denoting the second column of the matrix 'MEETINGS'.
For each test case, return the array of conflicting meetings.
The output is '1' if the returned conflicting meetings array is correct, otherwise, it will print '0'.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^4
1 <= MEETING[i][0] < 10^9
MEETING[i][0] < MEETING[i][1] <= 10^9
Time Limit : 1 sec
The idea is to find the Conflicting Meeting for each meeting one by one. To find a Conflicting Meeting for any particular meeting, we will iterate through each meeting and check whether the two meetings overlap. If we reach the end of the matrix without finding any conflicting meeting, then we will set the index of the conflicting meeting as -1 for that element.
Here is the algorithm :
The idea is to sort the meeting intervals in ascending order based on the starting time. Then we will iterate through that sorted array, and for every element, we will need to check only the meeting which has the highest end time among all the meetings that have been traversed earlier. This can be done efficiently by storing the index of the meeting with the highest ending time and the highest ending time while iterating through the array and updating them whenever we find a meeting that has an ending time which is greatest among all the meetings traversed. While traversing the sorted array, whenever we will find two conflicting meetings, we will update the output array for both of the conflicting meetings.
Here is the algorithm :