Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyCalendarTwo {
- public:
- map<int, int> time;
- MyCalendarTwo() {
- }
- bool book(int start, int end) {
- time[start]++;
- time[end]--;
- int booked = 0;
- for(auto t : time) {
- booked += t.second;
- if(booked == 3) {
- time[start]--;
- time[end]++;
- return false;
- }
- }
- return true;
- }
- };
- /**
- * Your MyCalendarTwo object will be instantiated and called as such:
- * MyCalendarTwo* obj = new MyCalendarTwo();
- * bool param_1 = obj->book(start,end);
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement