From 2b9e7dd4e41c5320ea93db4be83ce5c36e263e9b Mon Sep 17 00:00:00 2001
From: 07subhadip <91666506+07subhadip@users.noreply.github.com>
Date: Fri, 27 Sep 2024 09:26:25 +0530
Subject: [PATCH 1/3] Create Solution.ts

---
 .../0700-0799/0731.My Calendar II/Solution.ts | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 solution/0700-0799/0731.My Calendar II/Solution.ts

diff --git a/solution/0700-0799/0731.My Calendar II/Solution.ts b/solution/0700-0799/0731.My Calendar II/Solution.ts
new file mode 100644
index 0000000000000..28dba25de72ab
--- /dev/null
+++ b/solution/0700-0799/0731.My Calendar II/Solution.ts	
@@ -0,0 +1,32 @@
+class MyCalendarTwo {
+    private events: [number, number][];
+    private overlaps: [number, number][];
+
+    constructor() {
+        this.events = [];
+        this.overlaps = [];
+    }
+
+    book(start: number, end: number): boolean {
+        for (const [s, e] of this.overlaps) {
+            if (Math.max(start, s) < Math.min(end, e)) {
+                return false;
+            }
+        }
+
+        for (const [s, e] of this.events) {
+            if (Math.max(start, s) < Math.min(end, e)) {
+                this.overlaps.push([Math.max(start, s), Math.min(end, e)]);
+            }
+        }
+
+        this.events.push([start, end]);
+        return true;
+    }
+}
+
+/**
+ * Your MyCalendarTwo object will be instantiated and called as such:
+ * var obj = new MyCalendarTwo()
+ * var param_1 = obj.book(start,end)
+ */

From 675f0bea198f50f2c1b75f4e1226a7077e0fc110 Mon Sep 17 00:00:00 2001
From: Libin YANG <contact@yanglibin.info>
Date: Fri, 27 Sep 2024 12:51:39 +0800
Subject: [PATCH 2/3] Update README.md

---
 .../0700-0799/0731.My Calendar II/README.md   | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/solution/0700-0799/0731.My Calendar II/README.md b/solution/0700-0799/0731.My Calendar II/README.md
index 04d8becf7d485..60195c75c0c02 100644
--- a/solution/0700-0799/0731.My Calendar II/README.md	
+++ b/solution/0700-0799/0731.My Calendar II/README.md	
@@ -208,6 +208,43 @@ func (this *MyCalendarTwo) Book(start int, end int) bool {
  */
 ```
 
+#### TypeScript
+
+```ts
+class MyCalendarTwo {
+    private events: [number, number][];
+    private overlaps: [number, number][];
+
+    constructor() {
+        this.events = [];
+        this.overlaps = [];
+    }
+
+    book(start: number, end: number): boolean {
+        for (const [s, e] of this.overlaps) {
+            if (Math.max(start, s) < Math.min(end, e)) {
+                return false;
+            }
+        }
+
+        for (const [s, e] of this.events) {
+            if (Math.max(start, s) < Math.min(end, e)) {
+                this.overlaps.push([Math.max(start, s), Math.min(end, e)]);
+            }
+        }
+
+        this.events.push([start, end]);
+        return true;
+    }
+}
+
+/**
+ * Your MyCalendarTwo object will be instantiated and called as such:
+ * var obj = new MyCalendarTwo()
+ * var param_1 = obj.book(start,end)
+ */
+```
+
 #### JavaScript
 
 ```js

From e9171fbb91e745f68ae41ebcc09f529568484307 Mon Sep 17 00:00:00 2001
From: Libin YANG <contact@yanglibin.info>
Date: Fri, 27 Sep 2024 12:51:57 +0800
Subject: [PATCH 3/3] Update README_EN.md

---
 .../0731.My Calendar II/README_EN.md          | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/solution/0700-0799/0731.My Calendar II/README_EN.md b/solution/0700-0799/0731.My Calendar II/README_EN.md
index b3f664980ff95..4cc78f852a9b6 100644
--- a/solution/0700-0799/0731.My Calendar II/README_EN.md	
+++ b/solution/0700-0799/0731.My Calendar II/README_EN.md	
@@ -206,6 +206,43 @@ func (this *MyCalendarTwo) Book(start int, end int) bool {
  */
 ```
 
+#### TypeScript
+
+```ts
+class MyCalendarTwo {
+    private events: [number, number][];
+    private overlaps: [number, number][];
+
+    constructor() {
+        this.events = [];
+        this.overlaps = [];
+    }
+
+    book(start: number, end: number): boolean {
+        for (const [s, e] of this.overlaps) {
+            if (Math.max(start, s) < Math.min(end, e)) {
+                return false;
+            }
+        }
+
+        for (const [s, e] of this.events) {
+            if (Math.max(start, s) < Math.min(end, e)) {
+                this.overlaps.push([Math.max(start, s), Math.min(end, e)]);
+            }
+        }
+
+        this.events.push([start, end]);
+        return true;
+    }
+}
+
+/**
+ * Your MyCalendarTwo object will be instantiated and called as such:
+ * var obj = new MyCalendarTwo()
+ * var param_1 = obj.book(start,end)
+ */
+```
+
 #### JavaScript
 
 ```js