FastPrepFewest Coins for an Amount
Problems/Fewest Coins for an Amount

Fewest Coins for an Amount

Capital One logoCapital One● MediumFULLTIMEINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Coin change comes up in three Capital One reports from 2018, 2019 and 2021. On the 2021 Power Day the interviewer wanted the answer written with recursion. The 2019 intern report and the 2018 report each name the problem in one line.

None of them fixes the rules. In this version a coin value may repeat without limit, an amount that no mix of coins reaches gives -1, and a zero amount gives 0. We cannot check recursion from outputs, so the editorial covers it as a follow-up. The limits are our choice.

Our version is about 90% the same as the reported questions.

Pay exactly amount using coins whose values appear in coins. A value can be used again and again. Return how few coins that takes, or -1 when amount cannot be paid exactly. Paying 0 takes 0 coins.

Function

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

Examples

Example 1

coins = [3,7,10]amount = 21return = 3

Three 7 coins make 21. Seven 3 coins also make 21, but that uses more coins, so the answer is 3. Grabbing 10 first does not help: 10 + 10 leaves 1, and a single 10 leaves 11, which no mix of 3s and 7s can pay.

Example 2

coins = [5,8]amount = 11return = -1

Try the number of 8 coins. With one, 3 is left, which is smaller than 5. With none, only multiples of 5 can be paid, and 11 is not one. Two 8s already pass 11. No mix works, so the answer is -1.

Example 3

coins = [9,20]amount = 47return = 4

47 = 20 + 9 + 9 + 9 uses four coins. Two 20s leave 7, which no 9 can cover, and 9s alone cannot reach 47 because it is not a multiple of 9.

Example 4

coins = [6,13]amount = 0return = 0

There is nothing to pay, so no coins are needed and the answer is 0, not -1.

Constraints

  • 1 <= coins.length <= 12
  • 1 <= coins[i] <= 2^31 - 1
  • All values in coins are different.
  • 0 <= amount <= 10^4

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Coin ChangeMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Coin ChangeKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Coin ChangePinterest · ONSITE INTERVIEWPinterest interview questions
  • Coin ChangeBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Choose a Shortest Path That Avoids BobGoogle · ONSITE INTERVIEWGoogle interview questions
  • Grid Robot Route with Charging PrioritiesUber · PHONE SCREEN · ONSITE INTERVIEWUber interview questions
  • Coin ChangeThe Walt Disney Company · OA · ONSITE INTERVIEWThe Walt Disney Company interview questions
  • Shortest Path Visiting All NodesInMobi · ONSITE INTERVIEWInMobi interview questions
  • Minimum Distance Matching in a ForestScale AI · PHONE SCREEN · ONSITE INTERVIEWScale AI interview questions
  • Path Through an O/X Grid Using Only Right and DownAmazon · PHONE SCREEN

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public int coinChange(int[] coins, int amount) {
        // Write your code here.
    }
}
Checking account…