Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def minimalNumberOfCoins(coins, price)
- coins = coins.sort.reverse
- x = 0
- number_of_coins = 0
- while (x < coins.length)
- while price - coins[x] >= 0
- number_of_coins = number_of_coins + 1
- price = price - coins[x]
- end
- x = x + 1
- end
- return number_of_coins
- end
Advertisement
Add Comment
Please, Sign In to add comment