Class Solution
-
- All Implemented Interfaces:
public final class Solution3592 - Inverse Coin Change.
Medium
You are given a 1-indexed integer array
numWays, wherenumWays[i]represents the number of ways to select a total amountiusing an infinite supply of some fixed coin denominations. Each denomination is a positive integer with value at mostnumWays.length.However, the exact coin denominations have been lost. Your task is to recover the set of denominations that could have resulted in the given
numWaysarray.Return a sorted array containing unique integers which represents this set of denominations.
If no such set exists, return an empty array.
Example 1:
Input: numWays = 0,1,0,2,0,3,0,4,0,5
Output: 2,4,6
Explanation:
Example 2:
Input: numWays = 1,2,2,3,4
Output: 1,2,5
Explanation:
Example 3:
Input: numWays = 1,2,3,4,15
Output: []
Explanation:
No set of denomination satisfies this array.
Constraints:
1 <= numWays.length <= 100<code>0 <= numWaysi<= 2 * 10<sup>8</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-