Subsets - Leetcode 78 - Recursive Backtracking (Python)

preview_player
Показать описание


Please check my playlists for free DSA problem solutions:

My Favorite Courses:

Data Structures & Algorithms:

Python:

Web Dev / Full Stack:

Cloud Development:

Game Development:

SQL & Data Science:

Machine Learning & AI:
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

Thank you for explaining drawing part in detail, especially the recursive backtracking part ! You made this concept so much easier!!!

SHIHJUIheh
Автор

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.

NavneetKaur-xq
Автор

this is gold, so intuitive . Thanks for this

chisomedoka
Автор

brilliant solution. you just got yourself a new subscriber :)

shubhambajaj
Автор

Thank you a lot for explaining the transitive parts of backtracking!

anothertechguy-qg
Автор

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.

FZRides
Автор

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

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

sampjm
Автор

Absolutely beautiful explanation. I loved it !!

vasachisenjubean
Автор

thanks Greg your explanations are the best!

christianjt
Автор

better than stp neetcode guy explanation

kenkaneki
Автор

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?

olaf
Автор

better than the neetcode guy respectfully

amanreh
Автор

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

nav
Автор

How did you get so good at explaining solutions? I want to get to the point where I can communicate in interviews the way you are communicating in this video. Any tips?

EquinoXReZ
Автор

I'll like to see how you slve subset ii with this pattern as well

DivineEdoka
Автор

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

GarouNguyen
Автор

My solution is just calculate combinations C(n, k) where k from 1 to n

PhươngNguyễnMinh-nk
Автор

Easy to understand for noob like me 👍🏻

anti-dn
Автор

bro why don't pick and pick is same backtrack(i+1) and why you recursion left i + 1 i don't understand

GarouNguyen