FastPrepMinimum Coins for a Target
Problems/Minimum Coins for a Target

Minimum Coins for a Target

Infosys logoInfosys● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Infosys new grad onsite interview. The report does not give the function interface, the limits, or what to return when it is impossible. Our version is about 90% the same as the reported question.

Given an integer array coins of positive denominations and a nonnegative integer target, return the minimum number of coins needed to sum exactly to target.

You may use each denomination any number of times. Return -1 when no combination reaches the target. A target of 0 requires 0 coins.

Function

minCoins(coins: int[], target: int) → int

Examples

Example 1

coins = [1,2,5]target = 11return = 3

The target can be formed as 5 + 5 + 1, using three coins, and no two-coin combination reaches 11.

Example 2

coins = [2]target = 3return = -1

No number of coins with denomination 2 can sum to 3.

Example 3

coins = [2,3]target = 0return = 0

The empty selection already has sum 0.

Constraints

  • 1 <= coins.length <= 200
  • 1 <= coins[i] <= 100000
  • 0 <= target <= 100000
  • Duplicate denominations may appear in coins.

More Infosys Onsite Interview questions

  • Delete Duplicate Employee RecordsONSITE INTERVIEW · Seen Nov 2026
  • Find Duplicate Employee RecordsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Insertion Steps to Make a String PalindromeONSITE INTERVIEW · Seen Nov 2026
  • Maximize the Even-Odd Index Product GapONSITE INTERVIEW · Seen Oct 2026
  • Minimum Nonadjacent Flips for an Alternating Binary StringONSITE INTERVIEW · Seen Oct 2026
  • Tenth-Highest Distinct SalaryONSITE INTERVIEW · Seen Oct 2026
  • Assign Cookies With Matching ParityONSITE INTERVIEW · Seen Sep 2026
  • Count Equal Code Pairs Within Distance KONSITE INTERVIEW · Seen Sep 2026
  • Daily Successful Transactions Per DepartmentONSITE INTERVIEW · Seen Sep 2026
  • Detect Substring In Any RotationONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Assign Escalations to TeamsAmazon · ONSITE INTERVIEW
  • Collatz Conjecture with Shared MemoizationBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
  • Distinct Subset SumsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Count Subsets With a Target SumSafe Security · ONSITE INTERVIEW
  • Knight Probability in ChessboardGoldman Sachs · ONSITE INTERVIEWGoldman Sachs 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
All Infosys interview questionsSee Infosys hiring insights
Saved
class Solution {
    public int minCoins(int[] coins, int target) {
      // write your code here
    }
}
Checking account…