

Let assume the given interval list is ‘[ [ 1, 4 ], [ 5, 10 ], [ 6, 9 ] ] so we return ‘2’ as our answer as the interval [ 6, 9 ] lies in the interval [ 5, 10 ] so we removed [ 6, 9 ] from the list hence remaining intervals left are ‘2’ so ‘2’ is our answer.
We can take two intervals even when their starting and ending time are same. For eg: [1,3], [3,5] can be taken together.
The first line of input contains a ‘T’ number of test cases.
The first line of each test case contains an integer ‘N’ denoting the size of the given interval list. Then, ‘N’ lines follow.
Each line contains two space-separated integers denoting the starting and ending points of the interval.
For each test case, print a single line containing the remaining intervals left in the list after removing intervals that lie in other intervals.
The output of each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 3000
0 <= arr[i][0], arr[i][1] < 10 ^ 9
Where ‘T’ is the number of test cases, ‘N’ is the size of the given list or we can say an array of array, and ‘arr[i][0]’ and ‘arr[i][1]’ represents the starting and ending points of the intervals.
Time Limit: 1 sec
The idea here is to use a brute force approach and compare each and every interval if any interval starting point is greater than or equal to any given interval starting interval and less than or equal to its ending interval we have to count that numbers.
Algorithm:
The idea here is to sort the given list on the basis of starting and ending intervals then we can simply compare them in a single loop.
Algorithm: