Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CollinShoop/805b9eee34a7df4e716cff43e852d8b1 to your computer and use it in GitHub Desktop.
Save CollinShoop/805b9eee34a7df4e716cff43e852d8b1 to your computer and use it in GitHub Desktop.
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