We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6bd4f9d + e1cf698 commit 8860fa0Copy full SHA for 8860fa0
1304. Find N Unique Integers Sum up to Zero
@@ -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