leetcode729

class MyCalendar {
public:
    MyCalendar() {
        
    }
    
    bool book(int start, int end) {
        auto it = m.lower_bound(start);
        if (it != m.cend() && it->first < end) return false;
        if (it != m.cbegin() && (--it)->second > start) return false;
            m[start] = end;
            return true;
    }
private:
    map<int, int> m;
};

猜你喜欢

转载自blog.csdn.net/weixin_36149892/article/details/80287261