731. My Calendar II

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)