id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

bryce.hulett@hotmail.com > makeChange
prev  |  next  |  chance

Make change optimally(this problem can't be solved with a greedy approach) Input: The array contains denominations of the coins you have available, paid is what the customer paid, and worth is what the item is worth. The customer will always pay more than what the item is worth. Output: Output the minimum number of coins you need to make change with the coins you have available.


makeChange([1, 3, 5, 6], 50, 39) → 2
makeChange([1, 10, 20], 54, 50) → 4
makeChange([5, 10, 25], 75, 45) → 2

...Save, Compile, Run (ctrl-enter)

public int makeChange(int[] ary, int paid, int worth){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 400 Post-solution available

Copyright Nick Parlante 2017 - privacy