#3592

Inverse Coin Change

medium · 51.5% accepted · 163 likes · top 41%

array · dynamic programming

⊣ practice⊣ open on leetcode ↗

Description

You are given a 1-indexed integer array numWays, where numWays[i] represents the number of ways to select a total amount i using an infinite supply of some fixed coin denominations. Each denomination is a positive integer with value at most numWays.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 numWays array.

Return a sorted array containing unique integers which represents this set of denominations.

If no such set exists, return an empty array.

Solution