leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0729.cpp (473B)


0 class MyCalendar { 1 typedef pair<int, int> record; 2 set<record> st; 3 4 public: 5 bool book(int estart, int eend) { 6 const record event(estart, eend); 7 const auto next = st.lower_bound(event); 8 9 if (next != end(st) && next->first < eend) return false; 10 if (next != begin(st)) { 11 const auto prv = prev(next); 12 if (prv->second > estart) return false; 13 } 14 15 st.insert(event); 16 return true; 17 } 18 };