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
很像統(tǒng)計CPU Peak的做法,存儲每個時間段的起始節(jié)點,遍歷到起點加一,終點減一,if peak >= 3即為非法。