Skip to content

Instantly share code, notes, and snippets.

@fida10
Created August 20, 2022 01:18
Show Gist options
  • Save fida10/1345ad82b6672cc8f4943dacaf4269e3 to your computer and use it in GitHub Desktop.
Save fida10/1345ad82b6672cc8f4943dacaf4269e3 to your computer and use it in GitHub Desktop.
class Solution:
def sumZero(self, n: int) -> List[int]:
ans = [];
subtract = 0;
while (len(ans) < n - 1):
numToAdd = n - subtract;
ans.append(numToAdd)
ans.append(numToAdd * -1)
subtract += 1;
if (n % 2 != 0):
ans.append(0);
return ans;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment