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