Pascal's Triangle II

ID: 119; easy

Solution 1

func getRow(rowIndex int) []int {
    res := make([]int, rowIndex + 1)
    res[0] = 1
    for i := 1; i < rowIndex+1; i++ {
        res[i] = res[i-1] * (rowIndex-i+1) / i
    }
    return res
}
(nm)=(nm1)×nm+1m{n\choose{m}}={n\choose{m-1}} \times \frac{n-m+1}{m}

Last updated

Was this helpful?