Advertisement
nikunjsoni

732

May 26th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. class MyCalendarThree {
  2. public:
  3.     map<int, int> time;
  4.     MyCalendarThree() {
  5.        
  6.     }
  7.    
  8.     int book(int start, int end) {
  9.         time[start]++;
  10.         time[end]--;
  11.         int ans=0, current=0;
  12.         for(auto t: time)
  13.             ans = max(ans, current+=t.second);
  14.         return ans;
  15.     }
  16. };
  17.  
  18. /**
  19.  * Your MyCalendarThree object will be instantiated and called as such:
  20.  * MyCalendarThree* obj = new MyCalendarThree();
  21.  * int param_1 = obj->book(start,end);
  22.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement