

If a core is busy executing task-1 then it won’t be able to execute task-2 if the starting time of task-2 is less than the end time of task-1.
If N = 4 and the timestamps of the tasks are: { {0,10}, {5,20}, {10,25}, {30,40} }
Then the minimum number of cores required is equal to 2.
Task-1 will arrive at 0 and core-1 will execute it till 10.
Task-2 will arrive at 5 and as core-1 is busy executing task-1, so core-2 will be assigned and it will execute this task till 20
Task-3 will arrive at 10, core-1 has just finished executing task-1 and is now free, so core-1 will execute this task till 25.
Task-4 will arrive at 30, both core-1 and core-2 are free and any one of them will execute this task.
The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows:
The first line of each test case contains a single integer ‘N’ denoting the number of tasks to be executed.
The following N line each contains two integers ‘Start[i]’ and ‘End[i]’ denoting the time-stamp of the ith task.
For each test case, print a single integer denoting the minimum number of cores required.
Output for each test case will be printed in a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 1000
0 <= Start[i] < End[i] <= 1’000’000
Time limit: 1 sec
Sort all the tasks in increasing order of their start time. Now maintain a min-heap to store the ending time of all the tasks currently being executed.
Use a variable to store the current size of the min-heap, and the maximum value of this variable while processing each task one by one will be returned as our final answer.
For each task remove the tasks with ending time less than or equal to the start time of the current process as these tasks have already finished executing. Now insert the end time of the current time into the min-heap and proceed to the next task.
The steps are as follows :