Skip to content

Instantly share code, notes, and snippets.

@wambu-i
Created June 13, 2020 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wambu-i/6490763e93642aaef9698bdc299dcafe to your computer and use it in GitHub Desktop.
Save wambu-i/6490763e93642aaef9698bdc299dcafe to your computer and use it in GitHub Desktop.
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