Skip to content
Merged
Changes from 23 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions solution/0700-0799/0729.My Calendar I/Solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var MyCalendar = function () {
this.calendar = [];
};

/**
* @param {number} start
* @param {number} end
* @return {boolean}
*/
MyCalendar.prototype.book = function (start, end) {
for (const item of this.calendar) {
if (end <= item[0] || item[1] <= start) {
continue;
}
return false;
}
this.calendar.push([start, end]);
return true;
};

/**
* Your MyCalendar object will be instantiated and called as such:
* var obj = new MyCalendar()
* var param_1 = obj.book(start,end)
*/