Valid Parentheses - Stack - Leetcode 20 - Python

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


0:00 - Read the problem
1:25 - Drawing Explanation
7:20 - Coding Explanation

leetcode 20

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

Thanks. Also you can add a check on top if the size of the string is odd. And if its is, return false before checking anything else. Because that's just O(1) check assuring that anything can be closed at all (you can't close each bracket if the sum of chars is not even).

mightyplayer
Автор

A base case can be added at the beginning that checks if the string length is odd and if so return false.
This can optimize the time to O(1) if the string is odd (since there will be one bracket without a pair).

erandro
Автор

Better explanation than all the "Google employees" creating tutorials

cvxcfv
Автор

this channel has been a blessing, please keep updating this channel :')

meBZcookie
Автор

Man I got asked this question today and totally bombed it. I had a recursive implementation that kind of worked but missed a bunch of cases. Well back to learning it is. Your channel and experience is a truly godsent.

nelsonfleig
Автор

I was in the ball park with the hashmap, the stack, and the general idea, but handling the edge cases stumped me. Streamlined your code on my end just to make sure I understand it, thanks!

cxsey
Автор

just changing the last return to: return stack == [] makes the runtime MUCH BETTER

danielazulay
Автор

luv that u explain the detail to all levels, like why a stack is helpful here & you lead listeners to suspect such a thing themselves ... super kind way, directly helpful 2 getting ppl into the mindset of solving these problems. mad thx

melicanpelican
Автор

I only use c++ but I like looking at your explanations since you make it so simple to understand.

hangovercub
Автор

You’re actually good, I really hope I don’t fumble this opportunity and I get what I want with this

Emorinken
Автор

Very straightforward explanation, thank you!

singletmat
Автор

You did it way smarter than what I tried to. I made a hash table but I did one where the opening parentheses are they keys not the vales, the other way way is much simplier.

expansivegymnast
Автор

Hey, just want to let you know that I absulutely LOVE neetcode and all your videos. I'm a huge fan! Also, the code that you have on neetcode for this problem is a little different. I like the one from this video a lot better!

oiramormedeiros
Автор

i also used the stack data structure but use the if and else conditions therefor i came here to see more optimal and easy way and i got what i expect from your channel, thank you so much.

EjazAhmed-pftz
Автор

This problem is extremely difficult for me. Thank you for your tutorial once again.

ahyungrocks
Автор

The fact that this is easy is a little discouraging considering I fumbled around with it for several hours since I didn't know what a stack is. Glad to be able to learn this now though!

christianondo
Автор

Thank you for sharing with us all your knowledge, its a big thing to do

heyyou
Автор

Your explanation was perfect, yet I'm afraid I didn't understand that I wasn't able to solve this problem because I didn't know how to work with stack data structures. Good job my friend!

wildworldexplorerstv
Автор

Super helpful! Had trouble doing this on my own, learned a lot by doing your approach.

Melvinn
Автор

How the hell is this considered an easy problem?
I definitely need more work -.-

peterkim