FastPrepCoin Change
Problems/Coin Change

Coin Change

Kotak Mahindra Bank logoKotak Mahindra Bank● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source report identifies the linked Coin Change task. The callable signature, examples, and execution bounds reuse the equivalent reviewed FastPrep task; estimated source fidelity is 95%.

You are given an array coins of distinct positive coin denominations and a nonnegative integer amount.

You have an unlimited supply of every denomination. Return the minimum number of coins needed to make exactly amount. If no combination can make the amount, return -1.

An amount of 0 requires 0 coins.

Function

coinChange(coins: int[], amount: int) → int

Examples

Example 1

coins = [1,2,5]amount = 11return = 3

Two coins of denomination 5 and one coin of denomination 1 make 11 with three coins.

Example 2

coins = [2]amount = 3return = -1

No number of coins with denomination 2 can make the odd amount 3.

Example 3

coins = [1]amount = 0return = 0

The empty selection makes amount 0.

Constraints

  • 1 <= coins.length <= 12.
  • 1 <= coins[i] <= 2^31 - 1.
  • All denominations are distinct.
  • 0 <= amount <= 10000.

More Kotak Mahindra Bank problems

  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell Stock IIONSITE INTERVIEW · Seen Nov 2026
  • Maximum Non-Adjacent Coins in Two RowsONSITE INTERVIEW · Seen Oct 2026
All Kotak Mahindra Bank interview questionsSee Kotak Mahindra Bank hiring insights
Saved
class Solution {
    public int coinChange(int[] coins, int amount) {
        // write your code here
    }
}
Checking account…