Original post

at first, i think this may be due to use of direct copy

dp[i]=dp[i-1]

but after changing it to

// dp[i]=dp[i-1]
dp[i] = make([][]int, len(dp[i-1]))
copy(dp[i], dp[i-1])

it still doesn’t work