← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/LinkedIn/Leetcode 40. Combination Sum II
CodingMust
You are given a collection of candidate numbers and a target value. Your task is to find all distinct combinations of candidates where the chosen numbers sum to the target.
Important considerations:
Example 1:
Input: candidates = [10, 1, 2, 7, 6, 1, 5], target = 8 Output: [[1, 1, 6], [1, 2, 5], [1, 7], [2, 6]] Explanation: The four unique combinations that sum to 8 are shown above
Example 2:
Input: candidates = [2, 5, 2, 1, 2], target = 5 Output: [[1, 2, 2], [5]] Explanation: We can use 1 and two 2s, or the single 5
Example 3:
Input: candidates = [1], target = 2 Output: [] Explanation: No combination can reach the target