Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add js solution to lc problem: No.0731 #3572

Merged
merged 30 commits into from
Sep 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a21b1e8
Create Solution.js
07subhadip Sep 23, 2024
324cc2b
Create Solution.js
07subhadip Sep 23, 2024
80634a8
Update Solution.js
yanglbme Sep 24, 2024
3680e8b
Delete solution/Solution.js
yanglbme Sep 24, 2024
7a18121
Update README.md
yanglbme Sep 24, 2024
46a2880
Update README_EN.md
yanglbme Sep 24, 2024
f4825db
Create Solution.js
07subhadip Sep 24, 2024
8c24319
Update Solution.ts
07subhadip Sep 24, 2024
d6f4c63
Merge branch 'main' into main
yanglbme Sep 24, 2024
9223b1f
style: format code and docs with prettier
yanglbme Sep 24, 2024
fa67038
Update Solution.ts
yanglbme Sep 24, 2024
cc15596
Update Solution.js
yanglbme Sep 24, 2024
313f6b5
Update README.md
yanglbme Sep 24, 2024
63ef10d
Update README_EN.md
yanglbme Sep 24, 2024
6ae183c
Create Solution.js
07subhadip Sep 25, 2024
5f7be59
Merge branch 'doocs:main' into main
07subhadip Sep 25, 2024
f77f588
style: format code and docs with prettier
07subhadip Sep 25, 2024
1b9ab60
Update README.md
yanglbme Sep 25, 2024
8b4d469
Update README_EN.md
yanglbme Sep 25, 2024
bf35864
Merge branch 'main' into main
acbin Sep 25, 2024
cb0c193
Create Solution.js
07subhadip Sep 26, 2024
5927c3d
Merge branch 'main' into main
yanglbme Sep 26, 2024
a4b0a17
style: format code and docs with prettier
yanglbme Sep 26, 2024
a5b3b01
Update README.md
yanglbme Sep 26, 2024
4316b1e
Update README_EN.md
yanglbme Sep 26, 2024
f5ef073
Create Solution.js
07subhadip Sep 27, 2024
279136f
Merge branch 'main' into main
yanglbme Sep 27, 2024
5ac3684
style: format code and docs with prettier
yanglbme Sep 27, 2024
6a90290
Update README.md
yanglbme Sep 27, 2024
59d7872
Update README_EN.md
yanglbme Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create Solution.js
  • Loading branch information
07subhadip authored Sep 27, 2024
commit f5ef0732a196c95f4bd53402eb04fb5b87fc1e8c
33 changes: 33 additions & 0 deletions solution/0700-0799/0731.My Calendar II/Solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

var MyCalendarTwo = function() {
this.events = [];
this.overlaps = [];
};

/**
* @param {number} start
* @param {number} end
* @return {boolean}
*/
MyCalendarTwo.prototype.book = function(start, end) {
for (let [s, e] of this.overlaps) {
if (Math.max(start, s) < Math.min(end, e)) {
return false;
}
}

for (let [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)
*/
Loading