0
0
DSA Cprogramming~10 mins

Coin Change Minimum Coins in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the minimum coins array with a large number.

DSA C
int minCoins[amount + 1];
for (int i = 0; i <= amount; i++) {
    minCoins[i] = [1];
}
minCoins[0] = 0;
Drag options to blanks, or click blank then click option'
Aamount + 1
B0
C-1
DINT_MAX
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 will make all values zero and break the logic.
Using -1 is invalid for minimum calculation.
2fill in blank
medium

Complete the code to loop through each coin for the current amount.

DSA C
for (int i = 1; i <= amount; i++) {
    for (int j = 0; j < [1]; j++) {
        if (coins[j] <= i) {
            // update minCoins[i]
        }
    }
}
Drag options to blanks, or click blank then click option'
Aamount
Bi
CnumCoins
Dcoins
Attempts:
3 left
💡 Hint
Common Mistakes
Using amount instead of numCoins causes out-of-bound errors.
Using coins as loop limit is invalid since coins is an array.
3fill in blank
hard

Fix the error in updating minCoins[i] to find the minimum coins needed.

DSA C
if (coins[j] <= i) {
    minCoins[i] = (minCoins[i] > minCoins[i - coins[j]] + 1) ? [1] : minCoins[i];
}
Drag options to blanks, or click blank then click option'
AminCoins[i - coins[j]] + 1
BminCoins[i] + 1
CminCoins[i - coins[j]]
Dcoins[j]
Attempts:
3 left
💡 Hint
Common Mistakes
Adding 1 to minCoins[i] instead of minCoins[i - coins[j]] causes wrong results.
Using coins[j] directly is incorrect.
4fill in blank
hard

Fill both blanks to return the correct result or -1 if no solution exists.

DSA C
return (minCoins[amount] == [1]) ? [2] : minCoins[amount];
Drag options to blanks, or click blank then click option'
Aamount + 1
B-1
C0
DINT_MAX
Attempts:
3 left
💡 Hint
Common Mistakes
Returning 0 instead of -1 when no solution exists.
Comparing with INT_MAX instead of amount + 1.
5fill in blank
hard

Fill all three blanks to complete the function signature and variable declarations.

DSA C
int [1](int* coins, int [2], int [3]) {
    int minCoins[amount + 1];
    // function body
}
Drag options to blanks, or click blank then click option'
AcoinChange
BnumCoins
Camount
DcoinsCount
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent parameter names.
Using coinsCount instead of numCoins.