Created
February 1, 2023 00:42
-
-
Save CollinShoop/805b9eee34a7df4e716cff43e852d8b1 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
func sumZero(n int) []int { | |
nums := make([]int, n)[0:0] | |
if n % 2 == 1 { | |
nums = append(nums, 0) | |
} | |
n /= 2 | |
for n > 0 { | |
nums = append(nums, -n) | |
nums = append(nums, n) | |
n-- | |
} | |
return nums | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment