HTMLify

LeetCode - Find N Unique Integers Sum up to Zero - Go
Views: 4 | Author: abh
func sumZero(n int) []int {
    var ans []int
    if n%2==1 {
        ans = append(ans, 0)
    }
    for i:=1;len(ans)!=n;i++ {
        ans = append(ans, +i)
        ans = append(ans, -i)
    }
    return ans
}

Comments