After looking at several other videos, I finally found one where all my questions were answered. Loved the simplicity of the explanation whether whiteboard, coding part or the complexity.
Hi Greg, I found your video very intuitive. Thanks for sharing such content. Can you please make a video on "Tower of Hanoi" problem using recursion. I am unable to catch the recursive logic behind it. Can you please do it Sir.
you can use a dp solution : fn(n)=fn(n-1)+{fn(n-1) and put element_n in every set that return by fn(n-1)},cache the result of f(n).,f(n-1)..... consider you need to solve all the fn(n) you can write a bottom up dp solution, consider for each fn(n) only need f(n-1) you can just maintain one layer of cache so basic case is {[element_1],[empty]} for every element in the array add this element to each set and add this set back to the result: so the 2nd iteration: {[element_1],[empty], [element_1,element_2],[element_2]} and so on sorry for my English
Great explanation, thanks. Is the time complexity not O(n * 2^n) - reason being that at each of the terminal nodes you need to copy the list, which is an O(n) operation?
Would backtracking have to do with recursion? Is it possible to solve this in a non-recursive way? I am asking because it's really difficult to understand the recursive implementation of the code unless you memorize it. Thanks again for you awesome tutorials!!!! cheers
Master Data Structures & Algorithms For FREE at AlgoMap.io!
Thank you for explaining drawing part in detail, especially the recursive backtracking part ! You made this concept so much easier!!!
You're very welcome 😎
I've started understanding backtracking by that. In only 12 minutes. Thanks
After looking at several other videos, I finally found one where all my questions were answered. Loved the simplicity of the explanation whether whiteboard, coding part or the complexity.
Absolutely beautiful explanation. I loved it !!
Thank you a lot for explaining the transitive parts of backtracking!
brilliant solution. you just got yourself a new subscriber :)
this is gold, so intuitive . Thanks for this
better than stp neetcode guy explanation
thanks Greg your explanations are the best!
Bro I can see from the comments that you're just flying through these questions, good for you honestly!
Hi Greg,
I found your video very intuitive. Thanks for sharing such content. Can you please make a video on "Tower of Hanoi" problem using recursion. I am unable to catch the recursive logic behind it. Can you please do it Sir.
Nice video,helped me a lot!
what does backtrack(i +1) mean
I'll like to see how you slve subset ii with this pattern as well
bro how do you move recursion left what is line 12 code back track i + 1 , why you have two backtrack(i+1) can you explain bro
you can use a dp solution :
fn(n)=fn(n-1)+{fn(n-1) and put element_n in every set that return by fn(n-1)},cache the result of f(n).,f(n-1).....
consider you need to solve all the fn(n) you can write a bottom up dp solution,
consider for each fn(n) only need f(n-1) you can just maintain one layer of cache
so basic case is {[element_1],[empty]} for every element in the array add this element to each set and add this set back to the result:
so the 2nd iteration: {[element_1],[empty],
[element_1,element_2],[element_2]} and so on
sorry for my English
I'll have to look into this. Thanks so much for sharing!
Do you have a link to this? I want to learn it. Thanks.
many thanks.
thanks for explaning dfs in drawing
No problem!
Can you pls make a vid for subsets 2?
Easy to understand for noob like me 👍🏻
Oh that's so great to hear 😊
Great explanation, thanks. Is the time complexity not O(n * 2^n) - reason being that at each of the terminal nodes you need to copy the list, which is an O(n) operation?
You've inspired me, I was just wondering why we multiplied it by n.
indeed, I thing Gregg forgot the "n *" part of the time complexity, it's not O(2^n)
Great solution
Thanks so much!
Would backtracking have to do with recursion? Is it possible to solve this in a non-recursive way? I am asking because it's really difficult to understand the recursive implementation of the code unless you memorize it. Thanks again for you awesome tutorials!!!! cheers
You can memorize the template for how this is done, I promise the best way is through recursion
bro why don't pick and pick is same backtrack(i+1) and why you recursion left i + 1 i don't understand
thanks
I don't understand(
Maybe try watching it again? Backtracking is REALLY confusing at first