Go 3ms DP solution


  • 0
    M

    func change(amount int, coins []int) int {
    arr := make([]int, amount + 1)
    arr[0] = 1
    for _, c := range coins {
    if c <= amount {
    for i := 0; i < amount; i++ {
    if i + c <= amount {
    arr[i + c] += arr[i]
    }
    }
    }
    }
    return arr[amount]
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.