luoheng
12/30/2019 - 1:33 AM

sumZero

func sumZero(n int) []int {
    if n <= 0 {
        return []int{}
    }
    res := make([]int, n)
    for i := 0; i < n - 1; i++ {
        res[i] = i
    }
    res[n-1] = - ((n - 2) * (n - 1) >> 1) 
    return res
}