Advertisement
Aseron

Gechi

Oct 6th, 2017
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. public static int coinChangeGreedy(int[] coins, int n) {
  2.        
  3.             int sum_db = 0;
  4.             int c = coins.length-1;
  5.             int remaining_n = n;
  6.        
  7.                 while(c != -1){
  8.                     int db = remaining_n / coins[c];
  9.                     sum_db += db;
  10.                     remaining_n = remaining_n - db * coins[c];
  11.                     c--;
  12.                 }
  13.        return sum_db;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement