LeetCode 22. Generate Parentheses

  Рет қаралды 84,093

Nick White

Nick White

Күн бұрын

Пікірлер
@ashishranjan4623
@ashishranjan4623 5 жыл бұрын
At the stage of life your viewers usually might be, the fact that you are putting out all this content is more than enough, even if the explanation is not very precise. So don't feel bad, just keep uploading. You are really helping a lot.
@MrThepratik
@MrThepratik 4 жыл бұрын
"close < open" really saves a good deal of code . I was thinking to generate all possible combination and terminate if length exceeds or if its an unbalanced string
@surajdhar4484
@surajdhar4484 3 жыл бұрын
can you explain how "close< open" saves more time than "open>close"?
@JSDev776
@JSDev776 3 жыл бұрын
they will work exactly the same if that's all you're changing,
@sabisyed
@sabisyed 3 жыл бұрын
i was beating my head around this for hours and i think i went over your video atleast 8 times and i finally got it !! thanks a ton !
@projectsdb4034
@projectsdb4034 Жыл бұрын
Would love to see your walkthrough code complete on white board.
@sreekantht.m1964
@sreekantht.m1964 5 жыл бұрын
You have awesome teaching skills. Understood it in one go after watching ur vid.
@stuxvt
@stuxvt Жыл бұрын
Your discussion of making a template to backtracking, and working through the logic while adjusting input variables helped me solve "Letter Combinations of a Phone Number" using the same method without looking anything up. Thank you, feel much more confident on building elegant backtracking solutions.
@rakshith3547
@rakshith3547 4 жыл бұрын
Please plan to do whiteboarding and explaining the backtracking tree and what happens in the stack trace. That helps a lot compared to just typing the already existing solution!
@naveenkumarbr1111
@naveenkumarbr1111 4 жыл бұрын
Can you also please explain the big O for time and space with such problems, that would be very helpful. Great explaination !
@JM_utube
@JM_utube 4 жыл бұрын
good video, nick. honestly it takes a while to get backtracking, then to REALLY get backtracking
@deepeshkataria453
@deepeshkataria453 3 жыл бұрын
I was wondering how the solution is being checked , caz solution patterns are printed in any order!
@kaushal136
@kaushal136 4 жыл бұрын
So I have been doing leetcode and backtracking since 2 months and your 1 12 min video made me learn so much more ! Thnxx
@BhavyaBhaga
@BhavyaBhaga 4 ай бұрын
I am writing this comment and i really hope you read it. I love the way you solve problems, you keep the explanations so crisp & clean without extra talks. I learnt so much from you. I wish you the best Nick.
@deanhu3410
@deanhu3410 2 жыл бұрын
brilliant explanation. showing n = 2 as an example really helps.
@sunilraut4719
@sunilraut4719 3 жыл бұрын
I am following many youtubers over the year but when you explain a solution to a complex problem it just sounds easy, I really like your approach. Keep the good working going !!
@Firecloak
@Firecloak 4 жыл бұрын
The leetcode solution didn't make much sense to me, but your video clears it up!
@RK-nw1nq
@RK-nw1nq 4 жыл бұрын
Hi man, great video and an amazing explanation. Do you think you can make a video in the future explaining this code's time complexity? It would be very helpful. Thanks!!
@eugenevedensky6071
@eugenevedensky6071 3 жыл бұрын
I think the interesting part about your algo is that the if statements prevent us from creating redundant duplicate strings, which is really clever. I sovled this but ended up using a set to avoid the duplicates, which obviously screamed hack to me.
@suhailahmad6505
@suhailahmad6505 2 жыл бұрын
Just Amazing, don't have words about the way you have written the details of the recursive call, Thanks a lot man, appreciate your work
@xuehaizhou8335
@xuehaizhou8335 3 жыл бұрын
don't understand why backtrack doesn't generate duplicate strings. anyone can help me with it?
@sureshgarine
@sureshgarine 2 жыл бұрын
I really like the way you generalize how the template would be for backtracking, very nice explanation. Thank you nck. keep doing the good work to help us
@bellahasguns
@bellahasguns 4 жыл бұрын
love your video and expanation. could you do a walk thru on 131. Palindrome Partitioning, it is a backTracking as well, but having a hard time understand the step inside the recursion calls? appreciated.
@Rayyankhantheboss
@Rayyankhantheboss 3 жыл бұрын
as far as I know backtracking is going back, changing the solution and then recursing again, however u never backtracked u only recursed smartly making sure u chose valid paths
@suhailahmed278
@suhailahmed278 3 жыл бұрын
Could anyone tell me what is the time complexity of this solution? Please!
@Dani-zf7cu
@Dani-zf7cu Ай бұрын
Thanks so much Nick. Really helped me understand backtracking and it was pretty great and clean code.
@dipeshpandey4624
@dipeshpandey4624 3 жыл бұрын
Thanks for discussion and explanation, I believe this solution is also going to push 6th item as ()())(, so we might have to check the validity of parenthesis before pushing into the list in line 10. I checked with n = 3.
@MrVenona
@MrVenona 3 жыл бұрын
Went to a number of other pages/videos for this. You are the best! I don't need to search more!
@heisenberg1844
@heisenberg1844 4 жыл бұрын
Hi Nick. I really liked the explanation. Please do more backtracking problems. Thanks.
@anirudhbukka5413
@anirudhbukka5413 Жыл бұрын
Is this really backtracking? It seems to be just recursion, we are not "backtracking" to any point anywhere in the code.
@pranavsriram8
@pranavsriram8 5 жыл бұрын
Thanks man, really helped understand backtracking! Great video! You don't need to redo!
@pranav53465
@pranav53465 3 жыл бұрын
Great comment and great name
@rathan235
@rathan235 3 жыл бұрын
Hi Nick, thanks for the explanation. Can you please explain how to solve it with stack?
@sober_junkie5709
@sober_junkie5709 3 жыл бұрын
I never understood how the generation of the next combination started on it's own...
@LoLLuL-d5m
@LoLLuL-d5m 9 ай бұрын
is it really backtracking, I don't see where we are backtracking a decision we already made. we are not removing chars from the string that we already added.
@LoLLuL-d5m
@LoLLuL-d5m 9 ай бұрын
seems recursion to me. Explain pls
@yumo
@yumo 2 жыл бұрын
Implementation of this was really clean
@andresabello5639
@andresabello5639 4 ай бұрын
You are awesome at what you do. Keep in coming, my mentor!
@alphagrowth3327
@alphagrowth3327 2 жыл бұрын
Thanks for the solution and the dry run.
@yanchengpan543
@yanchengpan543 3 жыл бұрын
can you draw out a tree for this? plainly through recursion is still kinda hard to imagine
@kaustavprime3920
@kaustavprime3920 2 жыл бұрын
What's the space and time complexity of the solution?
@vanessachammas352
@vanessachammas352 5 жыл бұрын
super helpful, but if you could leave a link of ur notes so we could follow through that would be cool~
@ashutoshpandey1473
@ashutoshpandey1473 7 ай бұрын
Can somebody explain that why this solution is not working with StringBuilder instead of String?
@nirmal4343
@nirmal4343 4 жыл бұрын
Nice work!, what would be the time complexity?
@zacharysong4863
@zacharysong4863 2 жыл бұрын
It works if delete the line 11 return;
@shubhamkhurana7545
@shubhamkhurana7545 5 жыл бұрын
An Absolutely "WOW" Solution !!!
@NickWhite
@NickWhite 5 жыл бұрын
i feel like i fell off the leetcode train so bear with me while i get back up to speed
@shalin09
@shalin09 4 жыл бұрын
It will be good if you explain the time and space complexity after solving the problem. That would really help! Thanks in Advance :)
@pranavyeleti3499
@pranavyeleti3499 4 жыл бұрын
nick do u individually study or u study with another partner
@priyankagaikwad9909
@priyankagaikwad9909 3 жыл бұрын
what is the time complexity of this algorithm? Looks more than 2^n
@ujjvalsharma5055
@ujjvalsharma5055 4 жыл бұрын
Hey Nick I have been watching your videos for a quite some time now, and I wanted to say that you are doing a great job here. Keep it up :).
@aspa-n-fyt7785
@aspa-n-fyt7785 4 жыл бұрын
Hi! i i got 4 lines instead of 5 with n=3: ((())), (()()), ()(()), ()()() without (())(). what is the problem?
@OmarAhmed-od9rf
@OmarAhmed-od9rf 2 жыл бұрын
How does this esnures there are no duplicates?
@OmarAhmed-od9rf
@OmarAhmed-od9rf 2 жыл бұрын
insures*
@sauravthakur2915
@sauravthakur2915 2 жыл бұрын
Isn't this solution a recursive solution rather than backtracking ?
@InfoBuzz1130
@InfoBuzz1130 2 жыл бұрын
My favourite youtuber. love your vids man
@wardenofthenorth-w5d
@wardenofthenorth-w5d 4 жыл бұрын
Wow... I knew you years ago but never spent time watching y. It's amazing...
@sasivardhanbonthu8159
@sasivardhanbonthu8159 3 жыл бұрын
Already open=2 at starting but int close less than open you wrote 0 less than 1 but open =2 know?
@helperclass
@helperclass 3 жыл бұрын
Explanation was really helpful. Thanks!!
@nking99t
@nking99t Жыл бұрын
So this is a Greedy Strategy right? it is hard to demonstrate close < open will output the valid ones. so you just need to remember the answer. if this is your first time seeing this question, it may be hard to comes up with this strategy.
@amansayer4943
@amansayer4943 Жыл бұрын
imagine if he uses a board to teach this stuff it will be cleared in one go
@aman6561
@aman6561 4 жыл бұрын
it's one of the best explaination mate.
@bhavukpahuja269
@bhavukpahuja269 3 жыл бұрын
Great Explanation. Completely understood.
@dev-skills
@dev-skills 3 жыл бұрын
backtracking very well explained.
@nagalakshmichithambaranath1147
@nagalakshmichithambaranath1147 4 жыл бұрын
Wow, this backtracking never gets into my brain. you explained it so nicely.
@vasubhatnagar3352
@vasubhatnagar3352 4 жыл бұрын
please can you help me understanding backtracking..i'm trying from past 2 months but failing miserably.
@nagalakshmichithambaranath1147
@nagalakshmichithambaranath1147 4 жыл бұрын
@@vasubhatnagar3352 any recursive backtracking can be assured achieved by iterative breadth first search. If you are comfortable with iteration, you can try that.. word search by Nick white covers one such..
@nagalakshmichithambaranath1147
@nagalakshmichithambaranath1147 4 жыл бұрын
@@vasubhatnagar3352 backtobackswe also covered backtracking recursion.. solving Sudoku or solving maze can be achieved by recursive backtracking. Don't lose hope.. just keep trying
@himanshurajpal7842
@himanshurajpal7842 Жыл бұрын
Is this backtracking? You only used recursion
@pacificknight414
@pacificknight414 4 жыл бұрын
Very clear explanation, thank you very much!
@killingjoyandmemeing
@killingjoyandmemeing 3 жыл бұрын
Found Goldddddd!! Thanks man
@chiragaparadh1417
@chiragaparadh1417 3 жыл бұрын
I thought we would use those Catalan numbers here...
@raaghaviravisankar1853
@raaghaviravisankar1853 3 жыл бұрын
Thanks for such precise neat explanation
@gopikrishnan8182
@gopikrishnan8182 4 жыл бұрын
Good explanation. Thanks Nick
@rahulmistry9173
@rahulmistry9173 4 жыл бұрын
Oh man! That was flawless....WOW man....
@handanunal4040
@handanunal4040 4 жыл бұрын
The video helped me a lot understanding the problem, thanks
@soffwhere
@soffwhere 2 жыл бұрын
Trying to solve this alongside you, set playback speed to 0.5X. You sound like a brilliantly hilarious drunk. Also-- thank you so much for your content!
@nathamuni9435
@nathamuni9435 3 жыл бұрын
thanks but plzz try to explain as neetcode does... pretty easy
@rak590
@rak590 4 жыл бұрын
Great video Nick. Thanks a lot!
@yutingsun1690
@yutingsun1690 2 жыл бұрын
if I change open + 1 to open++ it would not work, can anyone explain why?
@zacharysong4863
@zacharysong4863 2 жыл бұрын
Open++ will add "1"after that traverse, the thing you need is ++open.
@kunalkheeva
@kunalkheeva 2 жыл бұрын
perfect, thank you.
@xufengzheng1318
@xufengzheng1318 2 жыл бұрын
support from China!🥳Very good explanation
@yuzhudong8044
@yuzhudong8044 3 жыл бұрын
Crystal clear!
@ahmede7141
@ahmede7141 Жыл бұрын
Thanks a lot!
@AmolGautam
@AmolGautam 3 жыл бұрын
Thank you so much.
@liedebunker1253
@liedebunker1253 2 жыл бұрын
That's a much higher hand. I'm ashamed of myself.😓😓
@user32132x
@user32132x 5 жыл бұрын
Thanks 🙂 it was very helpful keep it up. 👍
@pepetikesavasiddhardha7852
@pepetikesavasiddhardha7852 2 жыл бұрын
nice and simple logic
@missionstatusactive8470
@missionstatusactive8470 3 жыл бұрын
ur good bro.....need guys like u who teaches ds LOLzzzz
@maarcusfonseca
@maarcusfonseca 10 ай бұрын
good explanation
@davaa847
@davaa847 4 жыл бұрын
Hey man, it was good. Thanks.
@hawsh3066
@hawsh3066 5 жыл бұрын
3 videos in 5 hrs XD
@AkshayKumar-xh2ob
@AkshayKumar-xh2ob 4 жыл бұрын
Great video
@Naton
@Naton 4 жыл бұрын
Please slow down on the scroll. Hard to follow. Might as well use pythontutor
@zachsun3893
@zachsun3893 3 жыл бұрын
you fuckin legend bro
@pradeepmehra6879
@pradeepmehra6879 4 жыл бұрын
Lovely !!
@triplestrikee875
@triplestrikee875 3 жыл бұрын
like it!
@abe10
@abe10 4 жыл бұрын
Great video this. Sadly he's pushing crap videos now a days 😔
Generate Parentheses - Stack - Leetcode 22
13:37
NeetCode
Рет қаралды 391 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
LeetCode 55. Jump Game (Algorithm Explained)
10:06
Nick White
Рет қаралды 78 М.
Self Taught Programmers... Listen Up.
11:21
Nick White
Рет қаралды 1,1 МЛН
How I Mastered Data Structures and Algorithms in 8 Weeks
15:46
Aman Manazir
Рет қаралды 145 М.
Generate all Balanced Parentheses
34:03
Aditya Verma
Рет қаралды 152 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 477 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 187 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 846 М.
LeetCode 442. Find All Duplicates in an Array (Solution Explained)
12:37
11. Generate Parantheses | The recursion question that I have asked the most in interviews! 🚀🚀
15:30
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН