0731-0740

731. My Calendar II $\star\star$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class MyCalendarTwo {
 public:
  MyCalendarTwo() {}

  bool book(int start, int end) {
    for (auto& [first, second] : overlaps)
      if (max(start, first) < min(end, second)) return false;

    for (auto& [first, second] : booked) {
      int s = max(start, first);
      int e = min(end, second);
      if (s < e) overlaps.emplace_back(s, e);
    }

    booked.emplace_back(start, end);
    return true;
  }

 private:
  vector<pair<int, int>> booked;
  vector<pair<int, int>> overlaps;
};

732. My Calendar III $\star\star\star$

733. Flood Fill $\star$

734. Sentence Similarity $\star$

735. Asteroid Collision $\star\star$

736. Parse Lisp Expression $\star\star\star$

737. Sentence Similarity II $\star\star$

738. Monotone Increasing Digits $\star\star$

739. Daily Temperatures $\star\star$

740. Delete and Earn $\star\star$