Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def countChange(money: Int, coins: List[Int]): Int = {
- def loop(amountChange: Int, coins: List[Int]):Int = {
- if (amountChange > money) 0
- else if (amountChange == money) 1
- else {
- loop(amountChange + coins.head, coins) +
- (if (coins.size > 1) loop(amountChange + coins.tail.head, coins.tail)
- else 0)
- }
- }
- loop(0,coins)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement