Share my java AC Solution

  • 0

    public class Solution {

    public int minMeetingRooms(Interval[] intervals) {
        Arrays.sort(intervals, new Comparator<Interval>(){
           public int compare(Interval i1, Interval i2){
               return, i2.start);
        PriorityQueue<Integer> endtime = new PriorityQueue<>();
        for(Interval inter: intervals){
            if(endtime.isEmpty()){ endtime.add(inter.end);}
                int e = endtime.peek();
                if(e<= inter.start){  // Not overlapped
                    endtime.poll();  // update
                endtime.add(inter.end); // add new end time
        return endtime.size();


Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.