Created
June 13, 2020 18:01
-
-
Save wambu-i/6490763e93642aaef9698bdc299dcafe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<int> sumZero(int n) { | |
if (n == 0 || n == 1) return std::vector<int>(1, 0);; | |
std::vector<int> result; | |
for (int i = 1; i <= n/2; i++) { | |
result.push_back(i); | |
result.push_back(-i); | |
} | |
if ((n%2) == 1) result.push_back(0); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment