File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
solution/0700-0799/0731.My Calendar II Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,43 @@ func (this *MyCalendarTwo) Book(start int, end int) bool {
208
208
*/
209
209
```
210
210
211
+ #### TypeScript
212
+
213
+ ``` ts
214
+ class MyCalendarTwo {
215
+ private events: [number , number ][];
216
+ private overlaps: [number , number ][];
217
+
218
+ constructor () {
219
+ this .events = [];
220
+ this .overlaps = [];
221
+ }
222
+
223
+ book(start : number , end : number ): boolean {
224
+ for (const [s, e] of this .overlaps ) {
225
+ if (Math .max (start , s ) < Math .min (end , e )) {
226
+ return false ;
227
+ }
228
+ }
229
+
230
+ for (const [s, e] of this .events ) {
231
+ if (Math .max (start , s ) < Math .min (end , e )) {
232
+ this .overlaps .push ([Math .max (start , s ), Math .min (end , e )]);
233
+ }
234
+ }
235
+
236
+ this .events .push ([start , end ]);
237
+ return true ;
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Your MyCalendarTwo object will be instantiated and called as such:
243
+ * var obj = new MyCalendarTwo()
244
+ * var param_1 = obj.book(start,end)
245
+ */
246
+ ```
247
+
211
248
#### JavaScript
212
249
213
250
``` js
You can’t perform that action at this time.
0 commit comments