Returns the minimum number of coins from given set,
which sum equals to given change. This is famous
problem from the dymanic programming:
https://en.wikipedia.org/wiki/Change-making_problem
- Source:
Parameters:
Name | Type | Description |
---|---|---|
coins |
Array
|
The sorted list of the coins used for the change. |
change |
Number
|
The change, which should be returned. |
Returns:
Array which contains the minimum coins from the given
list, required for the change.
Example
var minCoinsChange =
require('path-to-algorithms/src/others/min-coins-change')
.minCoinsChange;
var coins = minCoinsChange([1, 2, 3], 5); // [ 2, 3 ]