Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 891 Bytes

279. Given a list of N coins, their values (V1, V2, … , VN), and the total sum S. Find the minimum number of coins the sum of which is S (we can use as many coins of one type as we want), if it is not possible to select coins in such a way that they sum up to S then print '-1'. Example: Given coins with values 1, 3, and 5. And the sum S is 11. Output: 3, 2 coins of 3 and 1 coin of 5

File metadata and controls

35 lines (25 loc) · 891 Bytes