Skip to content

Commit 8860fa0

Browse files
authored
Create 1304. Find N Unique Integers Sum up to Zero (#879)
2 parents 6bd4f9d + e1cf698 commit 8860fa0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public:
3+
vector<int> sumZero(int n) {
4+
vector<int> ans;
5+
for(int i =n/2;i>=1;i--){ans.push_back(-i);}
6+
if(n%2!=0){ans.push_back(0);};
7+
for(int i =1;i<=n/2;i++){ans.push_back(i);}
8+
return ans;
9+
}
10+
};

0 commit comments

Comments
 (0)