Write a program to get the minimum set of currency notes required to return any amount till the highest amount. So, just using the currency notes from the returned list, we should be able to return any amount till the highest amount. If the highest amount is 20, we should be able to return 5 or 7 or 17 or 20, just using those notes.
Input (Integer) |
Output (List) |
1 |
[1] |
5 |
[1, 2, 2] |
79 |
[1, 2, 4, 8, 16, 32, 16] |
121 |
[1, 2, 4, 8, 16, 32, 58] |
999 |
[1, 2, 4, 8, 16, 32, 64, 128, 256, 488] |
4516 |
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 421] |
0 |
null |