Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int coinChangeGreedy(int[] coins, int n) {
- int sum_db = 0;
- int c = coins.length-1;
- int remaining_n = n;
- while(c != -1){
- int db = remaining_n / coins[c];
- sum_db += db;
- remaining_n = remaining_n - db * coins[c];
- c--;
- }
- return sum_db;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement