Given a value V and array coins[] of size M, the task is to make the change for V cents, given that you have an infinite supply of each of coins{coins1, coins2, …, coinsm} valued coins. Find the minimum number of coins to make the change. If not possible to make change then return -1.
- Time : O(nv)
- Space : O(v)
1 | class Solution { |