public int minMeetingRooms(int[][] intervals) { if (intervals == null || intervals.length == 0) return 0; Arrays.sort(intervals, new Comparator<int[]>(){ public int compare(int[] a, int[] b) { return a[0] - b[0]; } }); PriorityQueue<int[]> pq = new PriorityQueue(intervals.length, new Comparator<int[]>(){ public int compare(int[] a, int[] b) { return a[1] - b[1]; } }); pq.offer(intervals[0]); for (int i = 1; i < intervals.length; ++i) { int[] interval = pq.poll(); if (interval[1] <= intervals[i][0]) { interval[1] = intervals[i][1]; }else pq.offer(intervals[i]); pq.offer(interval); } return pq.size(); }