Efficient Interval Intersection With O(nlogn) Time Complexity
Merge intervals from two lists in O(nlogn) time, where n is the total number of intervals. Use a single list to combine and sort both input lists, then greedily find overlapping intervals.
Problem Tc : O(nlogn) for sorting the list + O(n) for traversal of the list Sc: O(n) for using the list O(2k) for using result list and res[] array //same as merge intervals class Solution { public int[][] intervalIntersection(int[][] firstList, int[][] secondList) { //put both the list in a single list 'list' List<int[]> list = new ArrayList<>(); for(int i =0;i<firstList.length;i++){ list.add(new int[]{firstList[i][0],firstList[i][1]}); } for(int i =0;i<secondList.length;i++){ list.add(new int[]{secondList[i][0],secondList...