Skip to content

Commit cb0c193

Browse files
authored
Create Solution.js
1 parent bf35864 commit cb0c193

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
var MyCalendar = function() {
3+
this.calendar = [];
4+
};
5+
6+
/**
7+
* @param {number} start
8+
* @param {number} end
9+
* @return {boolean}
10+
*/
11+
MyCalendar.prototype.book = function(start, end) {
12+
for (const item of this.calendar) {
13+
if (end <= item[0] || item[1] <= start) {
14+
continue;
15+
}
16+
return false;
17+
}
18+
this.calendar.push([start, end]);
19+
return true;
20+
};
21+
22+
/**
23+
* Your MyCalendar object will be instantiated and called as such:
24+
* var obj = new MyCalendar()
25+
* var param_1 = obj.book(start,end)
26+
*/

0 commit comments

Comments
 (0)