Meeting Rooms II
来源:互联网 发布:ccer金融数据库 编辑:程序博客网 时间:2024/05/16 13:23
/** * 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, new Comparator<Interval>(){ @Override public int compare(Interval a, Interval b){ return a.start - b.start; } }); PriorityQueue<Integer> queue = new PriorityQueue<>(); queue.offer(intervals[0].end); for (int i = 1; i < intervals.length; i++) { if (intervals[i].start >= queue.peek()) { queue.poll(); } queue.offer(intervals[i].end); } return queue.size(); } }
0 0
- *LeetCode-Meeting Rooms II
- [LeetCode253]Meeting Rooms II
- Meeting Rooms II
- Meeting Rooms II
- leetcode Meeting Rooms II
- Meeting Rooms II
- Meeting Rooms II
- 253 Meeting Rooms II
- 253. Meeting Rooms II
- 253. Meeting Rooms II
- [LeetCode 253] Meeting Rooms II
- Leetcode 253Meeting Rooms II
- [LeetCode 253] Meeting Rooms II
- LeetCode 253. Meeting Rooms II
- [LeetCode]Meeting Rooms II
- LeetCode 253. Meeting Rooms II
- Leetcode 252. Meeting Rooms & 253. Meeting Rooms II
- LeetCode 题解(255) : Meeting Rooms II
- Product of Array Except Self
- Minimum Size Subarray Sum
- 100多个优秀的互联网编程学习平台整理。
- UIButton无法响应点击事件
- Find the Celebrity
- Meeting Rooms II
- Maximum Size Subarray Sum Equals k
- Simplify Path
- comment/uncomment lines in Vim
- 查看CPU支持的指令集
- 《c primer plus》第一个程序first.c的编辑,编译与输出
- bitset
- Leetcode 383. Ransom Note
- Zookeeper Java客户端API的使用