Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99bd944

Browse files
committed
Day68
1 parent f3a46a3 commit 99bd944

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Day68/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @param {number[]} A
3+
* @param {number[]} B
4+
* @param {number[]} C
5+
* @param {number[]} D
6+
* @return {number}
7+
*/
8+
var fourSumCount = function (A, B, C, D) {
9+
10+
let map = {};
11+
let count = 0;
12+
13+
for (let i = 0; i < A.length; i++) {
14+
for (let j = 0; j < B.length; j++) {
15+
let sum = A[i] + B[j];
16+
17+
if (!(sum in map)) {
18+
map[sum] = 1;
19+
} else {
20+
map[sum]++;
21+
}
22+
}
23+
}
24+
25+
for (let i = 0; i < C.length; i++) {
26+
for (let j = 0; j < D.length; j++) {
27+
let sum = C[i] + D[j];
28+
29+
if (map[-sum] != null) {
30+
count += map[-sum]
31+
}
32+
}
33+
}
34+
35+
36+
return count;
37+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,6 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
151151

152152
|Day 66| [1485. Clone Binary Tree With Random Pointer](https://leetcode.com/problems/clone-binary-tree-with-random-pointer/) | [javascript]()|[:memo:](https://leetcode.com/problems/clone-binary-tree-with-random-pointer/)|Medium|
153153

154-
|Day 67| [98. Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/) | [javascript]()|[:memo:](https://leetcode.com/problems/validate-binary-search-tree/)|Medium|
154+
|Day 67| [98. Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/) | [javascript]()|[:memo:](https://leetcode.com/problems/validate-binary-search-tree/)|Medium|
155+
156+
|Day 68| [454. 4Sum II](https://leetcode.com/problems/4sum-ii/) | [javascript]()|[:memo:](https://leetcode.com/problems/4sum-ii/)|Medium|

0 commit comments

Comments
 (0)