FastPrepCombination Sum
Problems/Combination Sum

Combination Sum

Anduril logoAnduril● MediumFULLTIMEPHONE SCREEN

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported from an Anduril technical phone screen for a full-time software engineer role that the candidate had applied to online. After about ten minutes of introductions, the interviewer gave the known combination sum problem: from a list of distinct numbers, find every way to pick numbers, with repeats allowed, that add up to a target. The candidate needed a while to get the index right, then solved it. A second, cache-style question in the same call is not part of this problem. The candidate did not pass the round.

The report gives no limits, examples or output order. We kept the limits of the known problem. The known problem accepts the combinations in any order; to give one exact answer, we chose numbers in non-decreasing order inside each combination and combinations in lexicographic order. The examples are ours.

Our version is about 95% the same as the reported question.

candidates is an array of distinct integers, and target is an integer. Find all the ways to choose numbers from candidates so that the chosen numbers add up to target. Any number can be chosen more than once.

Only how many times each number is chosen matters, not the order of the choices: [2,2,3] and [3,2,2] are one combination, and it must appear only once.

Return the combinations in one fixed order. Inside each combination, put the numbers in non-decreasing order. Then list the combinations in lexicographic order, comparing numbers as integers: for example, [2,2,6] comes before [2,3,5] because 2 < 3 at the second position. 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,2,5]target = 10return = [[2,2,2,2,2],[2,2,6],[5,5]]

Three combinations add up to 10: 2 + 2 + 2 + 2 + 2, 2 + 2 + 6 and 5 + 5. Each one is written smallest number first, and they are listed in lexicographic order. No combination with 5 and 2 works: one 5 plus any number of 2s is odd, and two 5s already make 10, so there is no room for a 2.

Example 2

candidates = [10,4]target = 7return = []

10 is larger than 7, and 7 is not a multiple of 4, so nothing adds up to 7 and the answer is an empty list.

Example 3

candidates = [12,3,8]target = 12return = [[3,3,3,3],[12]]

3 + 3 + 3 + 3 and 12 both add up to 12. The numbers are compared as integers, so [3,3,3,3] comes before [12] because 3 < 12. 8 is in no combination: 12 - 8 = 4, and 4 cannot be made from 3s.

Constraints

  • 1 <= candidates.length <= 30
  • 2 <= candidates[i] <= 40
  • All numbers in candidates are distinct.
  • 1 <= target <= 40
  • For every input, fewer than 150 combinations add up to target.

More Anduril interview questions

  • Pacific Atlantic Water FlowPHONE SCREEN · Seen Aug 2026
  • Choose the Front Football TeamPHONE SCREEN · Seen May 2026
  • Maximum Visible DronesPHONE SCREEN · Seen Jun 2024
  • Build a Sorted Circular Singly Linked ListPHONE SCREEN · Seen Feb 2024
  • Sparse Vector Dot ProductPHONE SCREEN · Seen Apr 2021
  • Add Word and Suffix SearchONSITE INTERVIEW · Seen Aug 2026
  • Binary Tree Preorder TraversalONSITE INTERVIEW · Seen Aug 2026
  • Operator-First Array CalculatorONSITE INTERVIEW · Seen Aug 2026
  • Daily TemperaturesONSITE INTERVIEW · Seen Jun 2024
  • Highlighted Context WindowsONSITE INTERVIEW · Seen Jun 2024

Similar questions at other companies

  • Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
  • SubsetsTemu · PHONE SCREENTemu interview questions
  • PermutationsEPAM · PHONE SCREENEPAM interview questions
  • Expand Attribute CombinationsPinterest · PHONE SCREENPinterest interview questions
  • All Subsets with a Given SumApple · PHONE SCREENApple interview questions
  • Combination Sum with Unlimited ReuseIMC Trading · PHONE SCREENIMC Trading interview questions
  • SubsetsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Validate a Mahjong Hand PartitionDuolingo · PHONE SCREENDuolingo interview questions
  • Winning Draws for a Mahjong HandZip · PHONE SCREENZip interview questions
  • Count Plus and Minus Sign PatternsAdobe · PHONE SCREENAdobe interview questions
All Anduril interview questionsSee Anduril hiring insights
Saved
class Solution {
    public List<List<Integer>> combinationSum(int[] candidates, int target) {
        // Write your code here.
    }
}
Checking account…