Skip to content

Commit a5b3b01

Browse files
authored
Update README.md
1 parent a4b0a17 commit a5b3b01

File tree

1 file changed

+30
-0
lines changed
  • solution/0700-0799/0729.My Calendar I

1 file changed

+30
-0
lines changed

solution/0700-0799/0729.My Calendar I/README.md

+30
Original file line numberDiff line numberDiff 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 -->

0 commit comments

Comments
 (0)