Combination Sum - Leetcode 39 - Recursive Backtracking (Python)

  Рет қаралды 9,243

Greg Hogg

Greg Hogg

Күн бұрын

Пікірлер: 14
@GregHogg
@GregHogg 5 ай бұрын
Master Data Structures & Algorithms For FREE at AlgoMap.io!
@chisomedoka5651
@chisomedoka5651 7 ай бұрын
why is backtracking so hard!!!!!!! I feel dumb, thanks for you explanation. Currently watching for the fifth time
@anna-plink
@anna-plink 4 ай бұрын
You're not alone!!
@Johnson_Amah
@Johnson_Amah 2 ай бұрын
You are definitely not alone
@jithendragunuru
@jithendragunuru 2 ай бұрын
+1
@vinaylasetti4665
@vinaylasetti4665 10 күн бұрын
Backtracking is a mechanism formed by don't pick a choice and pick a choice approach to arrive at a target solution combination. As per my understanding, we can use backtracking technique whenever we have to deal with combinations. So If you ask why Backtracking? because without backtracking we would endup in duplicate combination of solutions. I hope this gives some light! Thanks
@ohmyoni
@ohmyoni 8 ай бұрын
I really like these recursive backtracking problems, you explain them well.
@GregHogg
@GregHogg 8 ай бұрын
Oh I'm really glad to hear that. Such a tricky topic, I'm glad I did okay 😊
@saleheen12
@saleheen12 2 ай бұрын
The graph showed in the video hurt my brain but when I saw the code. I realized, it's almost the same code as "Subsets" problem.
@jst8922
@jst8922 8 ай бұрын
What tool you use for digital whiteboard (3:43) ?
@mohammadrafi895
@mohammadrafi895 5 ай бұрын
You wanna teach too?
@BluAngy
@BluAngy 4 ай бұрын
That is Miro
@JoeTan-nq4fq
@JoeTan-nq4fq 15 күн бұрын
Using a for..loop seems easier def dfs(index: int, remainder: int, state: list) -> None: # Base Case if remainder < 0: return if remainder == 0: return result.append(state[:]) # Backtrack when the remainder is less than 0 for i in range(index, n): if (x := remainder - candidates[i]) >= 0: dfs(i, x, state + [candidates[i]]) else: return [2,3,5], 8 index = 0 1 2 canddidates[i] = 2,3,5 3,5 5 ________[ ]_________ / | \ i=0 __[2]__ [3] [5] / \ / \ i=0 [2,2] [2,3] [3,3] [3,5] / \ | i=0 [2,2,2] [2,2,3] [2,3,3] | i=0 [2,2,2,2]
@alichopping2703
@alichopping2703 3 ай бұрын
These videos are great, can you do one for Combination Sum II?
Combination Sum - Backtracking - Leetcode 39 - Python
15:10
NeetCode
Рет қаралды 340 М.
Permutations - Leetcode 46 - Recursive Backtracking (Python)
9:42
Clone Graph - Leetcode 133 - Graphs (Python)
13:38
Greg Hogg
Рет қаралды 5 М.
Subsets - Leetcode 78 - Recursive Backtracking (Python)
11:51
Greg Hogg
Рет қаралды 12 М.
Top K Elements in 6 minutes | LeetCode Pattern
6:23
AlgoMasterIO
Рет қаралды 6 М.
3Sum - Leetcode 15 - 2 Pointers (Python)
9:42
Greg Hogg
Рет қаралды 14 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 305 М.
LeetCode 39 | Combination Sum | Algorithm Explained (Java)
12:46
Xavier Elon
Рет қаралды 11 М.
Daily Temperatures - Leetcode 739 - Stacks (Python)
12:35
Greg Hogg
Рет қаралды 9 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 725 М.
Leetcode - Combination Sum (Python)
8:25
Timothy H Chang
Рет қаралды 13 М.