Created
August 20, 2022 01:18
-
-
Save fida10/1345ad82b6672cc8f4943dacaf4269e3 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
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