Skip to content

Commit 9785d48

Browse files
authored
Create 729. My Calendar I (#596)
2 parents c8837e4 + 378e03a commit 9785d48

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

729. My Calendar I

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class MyCalendar {
2+
public:
3+
vector<pair<int, int>> booked;
4+
5+
MyCalendar() {
6+
}
7+
8+
bool book(int start, int end) {
9+
for (auto &b : booked) {
10+
if (max(b.first, start) < min(b.second, end)) {
11+
return false;
12+
}
13+
}
14+
booked.push_back({start, end});
15+
return true;
16+
}
17+
};

0 commit comments

Comments
 (0)