Problem of the day
The first line contains an integer ‘T’ denoting the number of test cases. Then each test case is as follows.
The first input line of each test case contains an integer ‘N’ which denotes the number of pairs.
Next ‘N’ lines contain two space-separated integers denoting a pair.
For each test case, print the length of the longest chain which can be formed.
Print the output of each test case in a separate line.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= T <= 50
1 <= N <= 1000
0 <= pairs[i][0], pairs[i][1] <= 10^6
Time limit: 1 sec
2
2
3 6
4 5
2
2 4
6 9
1
2
For the first test case, one of the longest chains is (3, 6) of length 1.
For the second test case, the longest chain is (2, 4) -> (6, 9) and its length is 2.
2
3
1 2
2 3
3 4
1
7 8
2
1