DP_CoinChange

Run Settings
LanguagePython
Language Version
Run Command
# Input: sum = 4, coins[] = {1,2,3} # Output: 4 # Explanation: there are four solutions: {1, 1, 1, 1}, {1, 1, 2}, {2, 2} and {1, 3} # Input: sum = 10, coins[] = {2, 5, 3, 6} # Output: 5 # Explanation: There are five solutions: # {2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5} and {5,5} # Input: sum = 10, coins[] = {10} # Output: 1 # Explanation: The only is to pick 1 coin of value 10. # Input: sum = 5, coins[] = {4} # Output: 0 # Explanation: We cannot make sum 5 with the given coins def coinChange(sum, coins): pass print("Hello World!") sample1 = 4 sample_array1 = [1,2,3] result1 = coinChange(sample1,sample_array1) print(f"result1: {result1}") assert(result1 == 4) sample2 = 4 sample_array2 = [2,5,3,6] result2 = coinChange(sample2,sample_array2) print(f"result2: {result2}") assert(result2 == 5) sample3 = 4 sample_array3 = [10] result3 = coinChange(sample3,sample_array3) print(f"result3: {result3}") assert(result3 == 1) sample4 = 4 sample_array4 = [4] result4 = coinChange(sample4,sample_array4) print(f"result4: {result4}") assert(result4 == 0) print("good bye world")
Editor Settings
Theme
Key bindings
Full width
Lines