Algorithm · Geico · Medium
You are given an integer array coins, where each value denotes a coin denomination, along with an integer amount representing the target sum. Implement a function that returns the smallest number of coins whose values add up to amount. If no combination of the available denominations can produce the target, return -1. Example 1: Input: coins = [1, 2, 5], amount = 11 Output: 3 Explanation: 11 can be formed as 5 + 5 + 1. Example 2: Input: coins = [2], amount = 3 Output: -1…