FastPrepCombination Sum with Unlimited Reuse
Problems/Combination Sum with Unlimited Reuse

Combination Sum with Unlimited Reuse

Confluent logoConfluent● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names this standard algorithm exercise. We chose the function signature, the limits, the rules for fixed answers, and the examples.

Given an integer array candidates with distinct positive values and a nonnegative integer target, return every combination of candidate values whose sum is exactly target. Each candidate value may be reused any number of times.

Combination rules

  • A combination is determined by how many times each candidate value is selected. Different arrangements of the same selected values are one combination.
  • Represent each combination as a nondecreasing integer array. Return each distinct combination exactly once.
  • The input candidates may be in any order. Leave the supplied array unchanged.
  • If target = 0, return [[]]: the one empty combination.
  • If no combination reaches a positive target, return [].

Result order

Order the returned rows in decreasing numeric lexicographic order. Compare integer values from left to right; at the first unequal position, the row with the larger integer comes first. If one row is a prefix of the other, place the longer row first.

For example, [7] comes before [2,2,3], and [1,3] comes before [1,1,2]. Compare integers rather than their decimal strings.

Interview context

Candidates are distinct and may be reused without limit, as in the example candidates = [2,3,6,7], target = 7, output = [[7],[2,2,3]]. Recursion or DFS works well.

Function

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

Examples

Example 1

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

The combinations are [7] and [2,2,3]. Both sum to 7, and the row beginning with 7 comes first in decreasing numeric lexicographic order.

Example 2

candidates = [2]target = 1return = []

Every selected value is at least 2, so no combination can sum to 1.

Example 3

candidates = [1,2]target = 0return = [[]]

Selecting no values gives the empty combination, whose sum is 0. Positive candidates cannot form any other zero-sum combination.

Constraints

  • 0 <= candidates.length <= 6.
  • Every candidate value is a distinct integer in [1,30].
  • 0 <= target <= 20.
  • The candidates may be unsorted. Do not modify the supplied array.

Source note: Author-written prompt excerpt retained for source fidelity.

More Confluent Onsite Interview questions

  • Implement tail -nPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sudoku Board ValidationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sudoku Puzzle SolverPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Sequential Phrase Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Bounded Combination Sum with Signed CandidatesONSITE INTERVIEW · Seen Oct 2026
  • Detect a Silent SensorONSITE INTERVIEW · Seen Sep 2026
  • Build an Inverted Document IndexONSITE INTERVIEW · Seen Sep 2026
  • Word Search Across DocumentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Windowed Key-Value MapPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Get Best PriceONSITE INTERVIEW · Seen Apr 2025

Similar questions at other companies

  • Generate All Permutations of a NumberFleetx · ONSITE INTERVIEW
  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEW
  • Subsets IIBloomberg LP · ONSITE INTERVIEW
  • Generate Circular Student ArrangementsAmazon · ONSITE INTERVIEW
  • Enumerate Compatible Meeting SubsetsExpedia · ONSITE INTERVIEW
  • Partition into Equal-Sum GroupsPalo Alto Networks · ONSITE INTERVIEW
  • PermutationsEPAM · PHONE SCREEN
  • Combination Sum with Single-Use ValuesPinterest · PHONE SCREEN
  • Combination Sum with Unlimited ReuseNVIDIA · PHONE SCREEN
  • Sort by Checking PermutationsMercor · PHONE SCREEN
See Confluent hiring insights
Saved
class Solution {
    public List<List<Integer>> combinationSum(int[] candidates, int target) {
        // Return every unique combination in the required order.
    }
}
Checking account…