Pay Dollars Out in Euro Bills and Coins
Updated
Problem statement
A customer changes dollars US dollars into euros. One dollar buys rate euro cents, so the customer receives dollars × rate euro cents.
Pay that amount using as few pieces as possible. The available pieces, in euro cents, are the notes 50000, 20000, 10000, 5000, 2000, 1000 and 500, and the coins 200, 100, 50, 20, 10, 5, 2 and 1. Any piece can be used any number of times.
Return the value of every piece paid, from largest to smallest.
Function
dollarsToEuroPieces(dollars: int, rate: int) → int[]Examples
Example 1
dollars = 37rate = 92return = [2000,1000,200,200,2,2]37 dollars at 92 cents per dollar is 37 × 92 = 3404 euro cents, which is 34.04 euro. Paid out: a 20 note and a 10 note (30 euro), two 2-euro coins (34 euro), and two 2-cent coins for the last 4 cents. That is six pieces.
Example 2
dollars = 500rate = 110return = [50000,5000]500 × 110 = 55000 euro cents, or 550 euro: one 500 note and one 50 note.
Example 3
dollars = 1rate = 88return = [50,20,10,5,2,1]One dollar buys 88 euro cents. The fewest coins are 50, 20, 10, 5, 2 and 1 cent, which add up to 88.
Constraints
1 <= dollars <= 10^450 <= rate <= 150
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
- Maximum 69 NumberHSBC · ONSITE INTERVIEWHSBC interview questions
- Maximize the Chance of Selecting the Best CandidateGoogle · ONSITE INTERVIEWGoogle interview questions
- Spend a Budget Across Five Price TiersExpedia · ONSITE INTERVIEWExpedia interview questions
- Integer BreakAmazon · ONSITE INTERVIEW
- Maximum Bananas Delivered by a CamelStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
- UCB1 Multi-Armed Bandit TraceWayfair · ONSITE INTERVIEWWayfair interview questions
- Reach a Target by Adding CoordinatesJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
- Server InvestmentRippling · OARippling interview questions
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
- Particle Moves to TargetCresta · OACresta interview questions
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