https://leetcode.com/problems/my-calendar-ii/description/
class MyCalendarTwo {
public:
MyCalendarTwo() {
}
bool book(int start, int end) {
mp[start] ++;
mp[end] --;
int cnt = 0;
for(auto p: mp) {
cnt += p.second;
if (cnt >= 3) {
--mp[start];
++mp[end];
return false;
}
}
return true;
}
map<int, int> mp;
};