File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
solution/0700-0799/0729.My Calendar I Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -256,6 +256,36 @@ impl MyCalendar {
256256}
257257```
258258
259+ #### JavaScript
260+
261+ ``` js
262+ var MyCalendar = function () {
263+ this .calendar = [];
264+ };
265+
266+ /**
267+ * @param {number} start
268+ * @param {number} end
269+ * @return {boolean}
270+ */
271+ MyCalendar .prototype .book = function (start , end ) {
272+ for (const item of this .calendar ) {
273+ if (end <= item[0 ] || item[1 ] <= start) {
274+ continue ;
275+ }
276+ return false ;
277+ }
278+ this .calendar .push ([start, end]);
279+ return true ;
280+ };
281+
282+ /**
283+ * Your MyCalendar object will be instantiated and called as such:
284+ * var obj = new MyCalendar()
285+ * var param_1 = obj.book(start,end)
286+ */
287+ ```
288+
259289<!-- tabs:end -->
260290
261291<!-- solution:end -->
You can’t perform that action at this time.
0 commit comments