美文网首页
731. My Calendar II

731. My Calendar II

作者: Nancyberry | 来源:发表于2018-06-11 12:13 被阅读0次

https://leetcode.com/problems/my-calendar-ii/description/
https://leetcode.com/problems/my-calendar-ii/solution/#approach-1-brute-force-accepted
Evidently, two events [s1, e1) and [s2, e2) do not conflict if and only if one of them starts after the other one ends: either e1 <= s2 OR e2 <= s1. By De Morgan's laws, this means the events conflict when s1 < e2 AND s2 < e1.

https://leetcode.com/problems/my-calendar-ii/solution/#approach-2-boundary-count-accepted
很像统计CPU Peak的做法,存储每个时间段的起始节点,遍历到起点加一,终点减一,if peak >= 3即为非法。

相关文章

网友评论

      本文标题:731. My Calendar II

      本文链接:https://www.haomeiwen.com/subject/mboceftx.html