dp with dimensions [n + 1][k + 1] and fill it with zeros.i from 1 to n.
coins from 0 to k.
currentSum to 0.currentCoins from 0 to min(piles[i - 1].length, coins).
currentCoins > 0, increase currentSum by the value of the coin at piles[i - 1][currentCoins - 1].dp[i][coins] to the maximum of its current value and dp[i - 1][coins - currentCoins] + currentSum.dp[n][k] as the maximum total value of coins that can be taken.