FastPrepCombination Sum
Problems/Combination Sum

Combination Sum

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two new-grad reports from Bloomberg software engineer loops name this classic task. One lists it among the first-round questions of a 2025 new-grad process; the other places it in the first virtual onsite and says it was asked exactly as the well-known version. Neither report gives a statement, limits or an example.

Everything else here is our practice choice. The candidate values are all different and each may be used any number of times. Each combination is written smallest value first, and the combinations come back in dictionary order, with a shorter combination first when it is the start of a longer one. There are 1 to 30 values from 2 to 40, and the target is 1 to 20.

The judged task matches the reports at about 85%.

You are given an array candidates of different positive integers and an integer target. Return every combination of values from candidates whose sum is exactly target.

A value may be used any number of times in one combination. Two combinations are the same when they use each value the same number of times, so list each combination only once.

Write every combination with its values in increasing order (equal values side by side). Return the combinations in dictionary order: compare two combinations value by value from the front, and the one with the smaller value at the first difference comes first. If one combination is the start of the other, the shorter one comes first.

If no combination adds up to target, return an empty list.

Function

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

Examples

Example 1

candidates = [6,3,4]target = 12return = [[3,3,3,3],[3,3,6],[4,4,4],[6,6]]

Each value may be used any number of times. The ways to reach 12 are:

  • [3, 3, 3, 3]: 3 + 3 + 3 + 3 = 12.
  • [3, 3, 6]: 3 + 3 + 6 = 12.
  • [4, 4, 4]: 4 + 4 + 4 = 12.
  • [6, 6]: 6 + 6 = 12.

Each combination is written smallest value first. [3, 3, 3, 3] comes before [3, 3, 6] because their third values are 3 and 6, and 3 is smaller. No combination mixes 3 and 4: 3 + 4 = 7 leaves 5, which no mix of 3, 4 and 6 makes.

Example 2

candidates = [4,6]target = 9return = []

Every sum of 4s and 6s is even, so no combination reaches the odd target 9. The answer is an empty list.

Example 3

candidates = [7]target = 14return = [[7,7]]

The only way is to use 7 twice: 7 + 7 = 14.

Example 4

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

There are 4 ways to reach 9:

  • [2, 2, 2, 3]: 2 + 2 + 2 + 3 = 9.
  • [3, 3, 3]: 3 + 3 + 3 = 9.
  • [3, 6]: 3 + 6 = 9.
  • [9]: the value 9 on its own.

A combination like [3, 2, 2, 2] is the same choice as [2, 2, 2, 3], so it is not listed again.

Constraints

  • 1 <= candidates.length <= 30
  • 2 <= candidates[i] <= 40
  • All values in candidates are different.
  • 1 <= target <= 20

More Bloomberg LP Onsite Interview questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
  • SubsetsTemu · PHONE SCREENTemu interview questions
  • Unique Single-Use Sum CombinationsLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent interview questions
  • PermutationsEPAM · PHONE SCREENEPAM interview questions
  • Spaceship Equipment LoadoutJane Street · ONSITE INTERVIEWJane Street interview questions
  • Insert Addition and Multiplication OperatorsPinterest · ONSITE INTERVIEWPinterest interview questions
  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
  • Maximum Unique-Character Word SubsetMeta · ONSITE INTERVIEWMeta interview questions
  • All Subsets with a Given SumApple · PHONE SCREENApple interview questions

Interview reports that mention this question

  • Bloomberg New Grad Question Bank: 161 Questions (Part 1 of 2)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public List<List<Integer>> combinationSum(int[] candidates, int target) {
        // Write your code here.
    }
}
Checking account…