The max number of overlap is the same and the max number of times a start time is covered.

So we put all intervals in a list, and also a map to count the number of times each start time is covered.

Update the map each time we put in a new interval.

```
class MyCalendarTwo {
public:
vector<pair<int,int>> st;
map<int,int> mp;
MyCalendarTwo() {
}
bool book(int s, int e) {
for (auto it = mp.lower_bound(s); it != mp.end() && it->first < e; ++it) {
if (it->second >= 2) return false;
}
int cnt = 0;
for (auto &v:st) if (v.first <=s && v.second > s) ++cnt;
if (cnt >=2) return false;
for (auto it = mp.lower_bound(s); it != mp.end() && it->first < e; ++it)
++it->second;
mp[s] = cnt + 1;
st.push_back({s,e});
return true;
}
};
```