Week 9: Exercises

1. Smallest Number of Coins

a) Write a function int smallest_number(int[] coins, int sum) that takes a list of coin values and a sum that we wish to form. The function should return the smallest number of coins that are required to form the sum. Each coin may be used multiple times in the sum.

b) Modify your function so that it returns an int[] containing the actual coin values that are used in the sum.