Skip to content

Commit 64580d6

Browse files
authored
Update 729-my-calendar-i.js
1 parent 220fdaa commit 64580d6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

729-my-calendar-i.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,28 @@ MyCalendar.prototype.book = function (start, end) {
4747
* var obj = new MyCalendar()
4848
* var param_1 = obj.book(start,end)
4949
*/
50+
51+
// another
52+
53+
const MyCalendar = function() {
54+
this.s = new Set()
55+
};
56+
57+
/**
58+
* @param {number} start
59+
* @param {number} end
60+
* @return {boolean}
61+
*/
62+
MyCalendar.prototype.book = function(start, end) {
63+
for(let e of this.s) {
64+
if(Math.max(start, e[0]) < Math.min(end, e[1])) return false
65+
}
66+
this.s.add([start, end])
67+
return true
68+
};
69+
70+
/**
71+
* Your MyCalendar object will be instantiated and called as such:
72+
* var obj = new MyCalendar()
73+
* var param_1 = obj.book(start,end)
74+
*/

0 commit comments

Comments
 (0)