Complete the code to initialize the dp array with the base case for coin change.
int[] dp = new int[amount + 1]; dp[[1]] = 1;
The base case is that there is exactly 1 way to make amount 0: by choosing no coins.
Complete the code to loop through each coin in the coins array.
foreach (int [1] in coins) { // logic here }
The variable name 'coin' clearly represents each coin value in the coins array.
Fix the error in the inner loop to update dp correctly for coin change.
for (int x = [1]; x <= amount; x++) { dp[x] += dp[x - coin]; }
The loop should start from the coin value to avoid negative indices and correctly build up the dp array.
Fill both blanks to complete the method signature and return statement.
public int [1](int[] coins, int [2]) { // method body return dp[amount]; }
The method name 'CountWays' clearly describes the function. The parameter 'amount' matches the variable used inside.
Fill all three blanks to complete the dictionary comprehension that maps coin to number of ways for amounts greater than zero.
var ways = new Dictionary<int, int>(); for (int i = [1]; i <= [2]; i++) { ways[i] = dp[i] [3] 0 ? dp[i] : 0; }
The loop starts from 1 to amount. The condition checks if dp[i] is greater than 0 to assign dp[i], else 0.
