Coin Change
Updated
Problem statement
You are given coin denominations and a target amount. Return the fewest number of coins needed to make exactly that amount.
You may use each coin denomination any number of times. If the amount cannot be made, return -1.
Follow-up
Be ready to walk through brute-force, improved, and 1D dynamic-programming approaches.
Function
coinChange(coins: int[], amount: int) → intExamples
Example 1
coins = [1,2,5]amount = 11return = 311 = 5 + 5 + 1, so the minimum number of coins is 3.
Example 2
coins = [2]amount = 3return = -1No combination of coin 2 can make amount 3.
More Omnissa Onsite Interview questions
- Build and Check a Palindrome Linked ListONSITE INTERVIEW · Seen Sep 2026
- Find the CelebrityONSITE INTERVIEW · Seen Sep 2026
- Maximum All-Ones Square Side LengthONSITE INTERVIEW · Seen Sep 2026
- Maximum Subarray SumONSITE INTERVIEW · Seen Sep 2026
- Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Jul 2026
- Rotate Array RightONSITE INTERVIEW · Seen Jul 2026
Similar questions at other companies
- Count Subsets With a Target SumSafe Security · ONSITE INTERVIEW
- Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Minimum Coins for a TargetInfosys · ONSITE INTERVIEWInfosys interview questions
- Integer BreakAmazon · ONSITE INTERVIEW
- Knight Probability in ChessboardGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
- Maximum Subarray Sum with One DeletionOracle · ONSITE INTERVIEWOracle interview questions
- Best Time to Buy and Sell Stock IIKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Coin ChangeMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Count Staircases with Strictly Increasing StepseBay · ONSITE INTERVIEWeBay interview questions