Longest Valid Parentheses | Live Coding with Explanation | Leetcode - 32

preview_player
Показать описание
Detailed Explanation for Longest Valid Parentheses Leetcode problem.

To support us you can donate

Check out our other popular playlists:

If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful.

#coding #leetcode #programminglife #programmingisfun #programmer #tech #software #codinglife #leetcode
Рекомендации по теме
Комментарии
Автор

We hope you all are enjoying our videos!!! Don't forget to leave a comment!!! Please like the video to support us!!!

Questions you might like:

Struggling in a question??

Leave in a comment and we will make a video!!!🙂🙂🙂

AlgorithmsMadeEasy
Автор

you should at least dry run through full array...

MadForCs
Автор

Actually, I'm trying to solve this problem last 2 days but I cannot solve this problem, but today got it. Thank you, Brother.

ArifulIslam-vsiv
Автор

There is a "why we are doing this " missing in your video

vaibhavvishal
Автор

why is it necessary to go from left to right AND right to left? why isnt just one traversal enough for the O(1) space and O(n) time solution?

anonymoussloth
Автор

Thank you!! This is very efficient video. I did my own dry run and finally fully get it!

emmatime
Автор

Wow, you explained a hard question in an relatively easy way, bravo !

b
Автор

i didnt get why we push -1 initially ? i know if we dont push -1 then if the first char is ')' then else cond will run and it will do s.pop() which will give error if -1 not present in stack.... but if that isnt the case wont this cause any problem

ayushthakur
Автор

The awesome solution, again intuitive and easy to understand. However, how did you come up with the trick of using -1 at the bottom of the stack? Because I could not even after few attempts at it. You coming up w/ the solutions so intuitively brings a genuine concern about whether do I have enough intelligence.

sumitrawat
Автор

Thanks for that solution. This approach is the easiest I have seen.

surendisodia
Автор

Amazing video ! Loved the without Extra space approach !

poorpanda
Автор

thank you so much for the solution! i have a question regarding the O(1) extra space non-dp solution : when we iterate from left to right, how do i come up with the condition that when open bracket count is less than close bracket count, i will need to reset open = close = 0 ? I missed this condition at first and submited a wrong answer

yuezhang
Автор

In 3rd approach
Why we do 2 itertions one from left to right and then right to left ?

pankajbhatt
Автор

Leetcode Solution me se hi answer chapne hai tho video kyu bana raha hai.

prathamkesarkar
Автор

i think for your O(1) space complexity approach this condition may fail when input is ")(".

pavanguntuboina
Автор

During 6:08 minutes, in line 15 and 16, we have kept a condition of if stack is empty, we need to push the current index, please provide me an intuition as of why this condition is important?

gazaljain
Автор

You offered the approaches without any logical explanations, thus coming across as having found the solution in your dreams. Although in reality, these are reproduced from the LeetCode editorial.

abhijit-sarkar
Автор

Please solve 1818. Minimum absolute sum difference leetcode problem 🙏🏼

Jyotikumari-zudg
Автор

This is going to fail for "()". the actual answer will be 4, while the expected answer is 2. To FIx this also reinitialise current =0, before iteretating in reverse order

abhishekanand
Автор

for ()(()()( your code is giving output as 3 but ans is 2

visheshjain