"Take the largest coin that fits, repeatedly" is correct for some coin systems and wrong for others. Write firstGreedyFailure(coins, limit): return the smallest amount from 1 to limit for which largest-coin-first greedy does not use the fewest possible coins, or -1 if there is no such amount.
- Greedy takes
Math.floor(amount / coin) of each coin from largest to smallest. If it cannot reach the amount exactly, it has failed, and that counts as a failure when some combination does reach the amount - If no combination reaches an amount, greedy and the optimum agree (neither can do it), so it is not a failure
- Coins are positive integers and need not include 1. Do not change
coins