Trains the technique from
LeetCode 3592Inverse Coin ChangeThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A mint used a set of coin face values, all distinct positive whole numbers. For an amount a, the number of ways to make a is the number of different multisets of those coins that total exactly a, so order never matters and a face value may be reused freely.
You are given numWays, where numWays[i] is the number of ways to make the amount i + 1. Every face value the mint used is at most numWays.length.
Return the face values the mint used, in increasing order. If no set of face values produces exactly these counts, return an empty list.
Example 1
With a single face value of 2 the amounts 2 and 4 can each be made one way, using one coin and two coins, while the amounts 1, 3 and 5 cannot be made at all.
Example 2
With a single face value of 1 each of the amounts 1 through 4 can be made exactly one way, by repeating that coin.
Example 3
The amount 1 can only ever be made by a single coin of face value 1, so it can never be made two ways and no set of face values fits.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def recover_denominations(numWays: list[int]) -> list[int]:public List<Integer> recoverDenominations(int[] numWays)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.