Combination Sum II
Updated
Problem statement
Return every distinct combination of values from candidates whose sum is target. Each input position may be used at most once. Equal values at different positions can both be used, but repeated position choices must not create duplicate value combinations.
Sort each combination in nondecreasing order and return the combinations in lexicographic order. Return [] when there is no solution.
Function
combinationSumOnce(candidates: int[], target: int) → int[][]Examples
Example 1
candidates = [10,1,2,7,6,1,5]target = 8return = [[1,1,6],[1,2,5],[1,7],[2,6]]All four distinct combinations sum to 8, and the pair of 1 values uses different positions.
Example 2
candidates = [2,5,2,1,2]target = 5return = [[1,2,2],[5]]The repeated 2 positions create only one value combination [1,2,2].
Constraints
1 <= candidates.length <= 20.1 <= candidates[i] <= 50.1 <= target <= 30.
More Expedia Onsite Interview questions
- Scramble StringONSITE INTERVIEW · Seen Sep 2026
- Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
- Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
- Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
- Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
- Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
- Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
- Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
- Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
- Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024
Similar questions at other companies
- Unique Single-Use Sum CombinationsLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent 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
- Subsets IIBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Generate Circular Student ArrangementsAmazon · ONSITE INTERVIEW
- Validate a Simplified Mahjong Winning HandGoogle · ONSITE INTERVIEWGoogle interview questions
- Combination Sum With Unlimited ReuseMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)