Skip to content

Commit 331436e

Browse files
committed
feat: add question 1304
1 parent 8694351 commit 331436e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

1304.data

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
5
2+
3
3+
1

1304.和为零的N个唯一整数.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* @lc app=leetcode.cn id=1304 lang=javascript
3+
*
4+
* [1304] 和为零的N个唯一整数
5+
*/
6+
7+
// @lc code=start
8+
/**
9+
* @param {number} n
10+
* @return {number[]}
11+
*/
12+
var sumZero = function(n) {
13+
const result = [];
14+
15+
if (n % 2 !== 0) {
16+
result.push(0);
17+
}
18+
19+
for (let i = 1; i <= n / 2; i++) {
20+
result.unshift(-i);
21+
result.push(i);
22+
}
23+
24+
return result;
25+
};
26+
// @lc code=end

0 commit comments

Comments
 (0)