LeetCode 39 | Combination Sum | Algorithm Explained (Java)

preview_player
Показать описание
The description reads:
"Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.

The same repeated number may be chosen from candidates unlimited number of times.

Note:

All numbers (including target) will be positive integers.
The solution set must not contain duplicate combinations.
Example 1:

Input: candidates = [2,3,6,7], target = 7,
A solution set is:
[
[7],
[2,2,3]
]"

Рекомендации по теме
Комментарии
Автор

The debugger really helped.... Thanks for showing the code through the debugger

abhigoku
Автор

Thank you no one else explained how the removal part working.Great video!! Keep Uploading

philipthomas
Автор

Thanks for explanation, video is really Great

DragonCode
Автор

this video is better than others as debugging clears more air

gauravswain
Автор

Would sorting the array before hand speed up run time. This way you could early terminate when !(candidates[i] <= target).

YuzuAndGin
Автор

lol ive watched like 10 videos about this question and all the other videos feel like they went to the solution section of leetcode and just vomitted out everything. this is the first video ive watched that went through why it removes the index for backtracking. thank you so much.

hidiribrahim
Автор

Thanks I was breaking my head over this

mojojojo
Автор

Very clear and nice explanation. Thank you so much!

rohanreddymelachervu
Автор

Thank you for your effort. I got confused by the use of the word Stack to refer to a List. Nowhere in the code you're using a stack.

saadbouayad
Автор

great explanation but i have one doubt the recursive function is only returning for (target==0) so how for the first case when there is 222 in the list it will return as the target is 1 now and it will loop though all the index and wont find any candidate to satisfy. i mean how will it remove top element??? thank you in advance

CrazyHunk
Автор

Why are you making a new arraylist when you hit target == 0. Can't you just use the current list and add it onto your res?

soumyajitchatterjee
visit shbcf.ru