FastPrepCombination Sum
Problems/Combination Sum

Combination Sum

BAMTECH Media logoBAMTECH Media● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a BAMTECH Media full-time phone screen. The author first describes using unlimited coins to make one dollar. Then the author says to add Combination Sum to the report. We follow that correction and list the combinations instead of only counting them. The original limits and interfaces are missing. So here the target can be any amount up to 100 cents, the coin values are different positive numbers, the results come in a fixed order, and there are at most 300 combinations per input. About 85% of the reported task is covered. This is our own estimate, not a comparison with the original code.

Given distinct positive denominations candidates and a positive integer target, return every different combination of denominations whose sum equals target. Each denomination may be used any number of times.

Sort the values inside each combination in nondecreasing order, and list the combinations in lexicographic order. Combinations that differ only in the order of their values count as one. Return an empty list when no combination exists.

The target is in cents and can be any amount up to 100, where 100 cents is one dollar.

Function

combinationSum(candidates: int[], target: int) → List<List<Integer>>

Examples

Example 1

candidates = [2,3,6,7]target = 7return = [[2,2,3],[7]]

Both [2,2,3] and [7] add up to the target, and no other combination does. Reordering [2,2,3] does not make a new combination.

Example 2

candidates = [2,3,5]target = 8return = [[2,2,2,2],[2,3,3],[3,5]]

Only [2,2,2,2], [2,3,3] and [3,5] add up to the target. Each list is sorted, and the lists are in lexicographic order.

Constraints

  • 1 <= candidates.length <= 6
  • 1 <= candidates[i] <= 100
  • All candidate denominations are distinct.
  • 1 <= target <= 100
  • At most 300 different combinations satisfy an input.

More BAMTECH Media Phone Screen questions

  • Climbing StairsPHONE SCREEN · Seen Oct 2019
  • Top K Largest Values with Constant Auxiliary SpacePHONE SCREEN · Seen Sep 2019
  • Valid ParenthesesPHONE SCREEN · Seen Sep 2019

Similar questions at other companies

  • Sort by Checking PermutationsMercor · PHONE SCREENMercor interview questions
  • Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
  • SubsetsTemu · PHONE SCREENTemu interview questions
  • Optimal Account BalancingPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • PermutationsEPAM · PHONE SCREENEPAM interview questions
  • Word Break IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Optimal Account BalancingSalesforce · PHONE SCREENSalesforce interview questions
  • Find GPU Capacity and Drain a NodeTogether AI · PHONE SCREEN
  • Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • All Subsets with a Given SumApple · PHONE SCREENApple interview questions

Interview reports that mention this question

  • BAMTECH SWE and Data Engineer: 2 Experiences (Part 16 of 18)
See BAMTECH Media hiring insights
Saved
class Solution {
    public List<List<Integer>> combinationSum(int[] candidates, int target) {
        // Write your code here
    }
}
Checking account…