Merge overlapping intervals
for the given 5 intervals - [1,4], [3,5], [6,8], [10,12], [8,9]. Since intervals [1,4] and [3,5] overlap with each other, we will merge them into a single interval as [1,5]. Similarly [6,8] and [8,9] overlaps, we merge them into [6,9]. Interval [10,12] does not overlap with any interval. Final List after merging overlapping intervals: [1,5], [6,9], [10,12]
The first line of input contains an integer 'T' representing the number of the test case. Then the test case follows. The first line of each test case contains an integer 'N', the number of intervals. The second line of the test case contains 'N' integers, the starting integer of 'N' intervals. The third line of the test case contains 'N' integers, the ending integer of 'N' intervals.
For each test case, print 'S' lines, each contains two single space-separated integers 'a', and 'b', where 'S' is the size of the merged array of intervals, 'a' is the start time of an interval and 'b' is the end time of the same interval. Print the output of each test case in a separate line.
1 <= T <= 100 1 <= N <= 1000 0 <= start, finish <= 10^9 Where 'T' denotes the number of test cases, 'N' denotes the number of intervals respectively, 'start' and 'finish' are the starting and finishing times for intervals. Time Limit: 1 sec
Merge Two Sorted Arrays Without Extra Space
Sort 0s, 1s, 2s