253. Meeting Rooms II

/**
 * Definition for an interval.
 * public class Interval {
 *     int start;
 *     int end;
 *     Interval() { start = 0; end = 0; }
 *     Interval(int s, int e) { start = s; end = e; }
 * }
 */
public class Solution {
    public int minMeetingRooms(Interval[] intervals) {
        if(intervals==null||intervals.length==0) return 0;
        Arrays.sort(intervals,(a,b)->(a.start-b.start));
        int max=0;
        PriorityQueue queue=new PriorityQueue<>(intervals.length,(a,b)->(a.end-b.end));
        for(int i=0;i=queue.peek().end) queue.poll();
            queue.offer(intervals[i]);
            max=Math.max(max,queue.size());
        }
        return max;
    }
}
public class Solution {
    public int minMeetingRooms(Interval[] intervals) {
        int[] starts = new int[intervals.length];
        int[] ends = new int[intervals.length];
        for(int i=0; i

你可能感兴趣的:(253. Meeting Rooms II)