#3592

Inverse Coin Change

specialist · 860 · lc medium +31 · 51.5% accepted · 163 likes · top 41%

Description

A 1-indexed integer array numWays is given, where numWays[i] is the number of ways to form total i using unlimited coins from some unknown denomination set (each denomination is a positive integer at most numWays.length).

Reconstruct the coin denominations that produce exactly this numWays array.

Return the denominations as a sorted array of unique integers, or an empty array if no valid set exists.

Code

1
2
3