The Inverse Coin Change interview question is a creative twist on the classic coin change problem. Instead of finding the minimum coins to make a sum, you are given the results of a "minimum coins" function for various sums, and you need to reconstruct the original set of coin denominations.
Google uses the Inverse Coin Change coding problem to evaluate a candidate's ability to "reverse-engineer" an algorithm. It tests your understanding of Dynamic Programming foundations—specifically how state transitions build up. It’s a high-level test of logical deduction and mathematical modeling.
This problem relies on Greedy deduction within DP states.
dp[i] = 1 + min(dp[i - coin]).dp[i] == 1, then i itself must be a coin denomination.Input: sum 1: 1, sum 2: 1, sum 3: 2, sum 4: 2
{1, 2}.When asked to "invert" an algorithm, always write down the forward recurrence first. Seeing the forward logic dp[i] = f(dp[i-coin]) makes it much easier to see that the coins are the "base cases" where the function returns its minimal non-zero value.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Maximize Total Cost of Alternating Subarrays | Medium | Solve | |
| Minimum Increment Operations to Make Array Beautiful | Medium | Solve | |
| Zero Array Transformation IV | Medium | Solve | |
| Best Time to Buy and Sell Stock V | Medium | Solve | |
| Check if There is a Valid Partition For The Array | Medium | Solve |