Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add js solution to lc problem: No.0729 #3566

Merged
merged 25 commits into from
Sep 26, 2024
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)
*/