-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Time: 134 ms (71.42%), Space: 37.7 MB (87.88%) - LeetHub
- Loading branch information
1 parent
ee010a6
commit 61edce3
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class MyCalendar { | ||
public: | ||
MyCalendar() { | ||
|
||
} | ||
|
||
bool book(int start, int end) { | ||
for (auto c : cal) { | ||
if (max(c.first, start) < min(c.second, end)) { | ||
return false; | ||
} | ||
} | ||
cal.push_back({start, end}); | ||
return true; | ||
} | ||
|
||
private: | ||
vector<pair<int, int>> cal; | ||
}; | ||
|
||
/** | ||
* Your MyCalendar object will be instantiated and called as such: | ||
* MyCalendar* obj = new MyCalendar(); | ||
* bool param_1 = obj->book(start,end); | ||
*/ |