Skip to content

Commit 5a3d816

Browse files
authored
Create 1995-count-special-quadruplets.js
1 parent 05d394c commit 5a3d816

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

1995-count-special-quadruplets.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
const countQuadruplets = function(nums) {
6+
let res = 0
7+
for(let a = 0, n = nums.length; a < n - 3; a++) {
8+
for(let b = a + 1; b < n - 2; b++) {
9+
for(let c = b + 1; c < n - 1; c++) {
10+
for(let d = c + 1; d < n; d++) {
11+
if(nums[a] + nums[b] + nums[c] === nums[d]) res++
12+
}
13+
}
14+
}
15+
}
16+
17+
18+
return res
19+
20+
};

0 commit comments

Comments
 (0)