class Solution { public int minMeetingRooms(int[][] intervals) { Arrays.sort(intervals, (a, b) -> a[0] - b[0]); PriorityQueue pq = new PriorityQueue<>(); int maxSize = 0, start = -1, end = -1; for (int[] i : intervals) { while (!pq.isEmpty() && pq.peek() <= i[0]) { if (pq.size() == maxSize) { end = pq.peek(); // last active meeting's end before drop } pq.poll(); } pq.offer(i[1]); if (pq.size() > maxSize) { maxSize = pq.size(); start = i[0]; // track the start of the max overlap range } } // Handle case where the last interval is part of the max overlap if (pq.size() == maxSize) { end = pq.peek(); // final end if the max overlap lasts until the end } System.out.println("Max overlap was between " + start + " and " + end); return maxSize; } }