class MyCalendar {
public:
MyCalendar() {
}
bool book(int start, int end) {
rec[start]++;
rec[end]--;
int c = 0;
for(auto &r: rec) {
//cout << "1 > " << r.first << " - " << r.second << " c: " << c << endl;
c += r.second;
//cout << "2 > " << r.first << " - " << r.second << " c: " << c << endl;
if (c > 1) {
rec[start]--;
rec[end]++;
return false;
}
}
return true;
}
private:
map<int, int> rec;
};
/**
* Your MyCalendar object will be instantiated and called as such:
* MyCalendar obj = new MyCalendar();
* bool param_1 = obj.book(start,end);
*/