Leetcode 32 Longest Valid Parentheses

  Рет қаралды 17,429

Pratiksha Bakrola

Pratiksha Bakrola

Күн бұрын

Пікірлер: 74
@allasandeep1466
@allasandeep1466 5 ай бұрын
One of the best Solution , Mam do the leetcode problems like this way its very help to us
@sriracha9729
@sriracha9729 4 ай бұрын
ok sir
@nguyenbach4710
@nguyenbach4710 Жыл бұрын
plz don't stop the way u explained so clearly and specify thankyou very much
@pratikshabakrola
@pratikshabakrola Жыл бұрын
Hello Nguyen, Thank you for your feedback! Appreciate it! Will upload more videos soon!
@kartikeyasingh5172
@kartikeyasingh5172 3 ай бұрын
Excellent solution , this one is more intutive , as compared to stack one.
@priyanshu5407
@priyanshu5407 8 ай бұрын
nice one
@pratikshabakrola
@pratikshabakrola 6 ай бұрын
Thanks
@snehal5429
@snehal5429 8 ай бұрын
My approach was same but I was not doing checking in reverse direction, thanks
@pratikshabakrola
@pratikshabakrola 6 ай бұрын
Great 👍
@ritikshandilya7075
@ritikshandilya7075 Ай бұрын
We really need more such great solutions , thanks for amazing explanation and approach.
@neetankumar4449
@neetankumar4449 Жыл бұрын
wasn't able to understand why two traversals : start to end and end to start, just understood, thanks bakrola mam
@pratikshabakrola
@pratikshabakrola Жыл бұрын
Glad it helped!
@phardik5610
@phardik5610 Ай бұрын
most clever solution out there for this question
@holly_singh
@holly_singh Жыл бұрын
great video, can you please make videos of graph questions ? Esp the ones that are not solved on other channels
@sivan2878
@sivan2878 10 ай бұрын
Great video, thanks a lot Pratiksha
@MR._NEEN
@MR._NEEN 3 ай бұрын
Your solution is very impressive . A like for you.
@pratikshabakrola
@pratikshabakrola 2 жыл бұрын
class Solution { public int longestValidParentheses(String s) { int left=0; int right=0; int max=0; for(int i=0;ileft) { left=0; right=0; } } left=0; right=0; for(int i=s.length()-1;i>=0;i--) { if (s.charAt(i)=='(') left++; else right++; if(left==right) { max=Math.max(max,left*2); }else if(left>right) { left=0; right=0; } } return max; } }
@MrVlog-04
@MrVlog-04 2 ай бұрын
nice approch to solve this question
@vninfo.2739
@vninfo.2739 Ай бұрын
wow this is very easy solution
@abhaychaurasiya5548
@abhaychaurasiya5548 Жыл бұрын
never found such clear explanation
@pratikshabakrola
@pratikshabakrola Жыл бұрын
Thanks for sharing! I am glad you found it helpful!
@triggeredinsaan_mini
@triggeredinsaan_mini 3 ай бұрын
One of the beat and easy solution
@JayPrajapati-lj8pw
@JayPrajapati-lj8pw Жыл бұрын
great maja aagaya
@shivamshukla438
@shivamshukla438 3 ай бұрын
Thank you good explanation
@PraveenKumar-kl2xi
@PraveenKumar-kl2xi 5 ай бұрын
nice solution, great logic
@AnkitPandey-s9h
@AnkitPandey-s9h 11 ай бұрын
very informative vedio
@Area-fd8ht
@Area-fd8ht 9 ай бұрын
Pratiksha explanation is too good also u are too cute 🥰
@pratikshabakrola
@pratikshabakrola 8 ай бұрын
Thank you!
@prashantbhati8705
@prashantbhati8705 7 ай бұрын
mast explain kiya hain :)
@barathkumar3583
@barathkumar3583 5 ай бұрын
Good
@mohammedilyas8824
@mohammedilyas8824 2 жыл бұрын
Ma'am pls make videos on most important questions for sde role fresher
@pratikshabakrola
@pratikshabakrola 2 жыл бұрын
Hello Mohammed, I will try to put something together on that topic. Thank you for suggesting that.
@singhji4149
@singhji4149 Жыл бұрын
Great explanation
@pratikshabakrola
@pratikshabakrola Жыл бұрын
Glad it was helpful!
@vvek_7
@vvek_7 Жыл бұрын
Very Clear
@pratikshabakrola
@pratikshabakrola Жыл бұрын
Glad to hear that
@sarojkumar-nu8vo
@sarojkumar-nu8vo 2 жыл бұрын
well explained great 👍
@pratikshabakrola
@pratikshabakrola 2 жыл бұрын
Thank you Saroj Ji 🙏 Make sure you share it with others who may find it helpful 😊
@mayurs9319
@mayurs9319 2 жыл бұрын
nice🎉
@pratikshabakrola
@pratikshabakrola 2 жыл бұрын
Glad you liked it ! Make sure to share it with your friends 🙏
@mayurs9319
@mayurs9319 2 жыл бұрын
@@pratikshabakrola I did ;)
@zeynepergul4768
@zeynepergul4768 Жыл бұрын
what if that would be a stack and they ask for thw range between indexes at longest parantheses
@ShivangiSingh-wc3gk
@ShivangiSingh-wc3gk 5 ай бұрын
Kind of feels like this solution is wrong
@vineeshashwin2697
@vineeshashwin2697 Жыл бұрын
🎉💥👑
@deepakkumar13204
@deepakkumar13204 Жыл бұрын
Well explained mam ❤
@pratikshabakrola
@pratikshabakrola Жыл бұрын
Thanks a lot 😊
@xyzhacker00999
@xyzhacker00999 2 ай бұрын
you and your solution is so beautiful
@feelyourbeat7820
@feelyourbeat7820 4 ай бұрын
I came here just to see her beauty ❤
@UnspokenTears
@UnspokenTears Жыл бұрын
class Solution { public int longestValidParentheses(String s) { int c=0; for(int i=0;i
@adi9003
@adi9003 10 ай бұрын
you are only considering strings which which have ')' just after '(' -> for example, ()()() but this code will fail to answer correctly when I give ((((())))), it is correct string but according to your logic it is not correct.
@gamerversez5372
@gamerversez5372 Жыл бұрын
I think you should give proper explanation why another traversal is needed
@pratikshabakrola
@pratikshabakrola Жыл бұрын
Good feedback! Thanks
@satyamchoudhary2573
@satyamchoudhary2573 11 ай бұрын
s = ")(", wrong for this input
@CodeWithSeenu
@CodeWithSeenu Ай бұрын
else if(l < r) { r = 0; l = 0; } not an issue
@Karthik-ev7jy
@Karthik-ev7jy 10 ай бұрын
Not working for some test cases
@vinaysen6710
@vinaysen6710 Жыл бұрын
Beauty with Talent
@24_Focus
@24_Focus 6 ай бұрын
turunin
@satyamchoudhary2573
@satyamchoudhary2573 11 ай бұрын
name se laga Indian hai but awaj se angrez , Kya bawasir hai 🤣, BTW nice explaination
@AmitKumar-fk8mm
@AmitKumar-fk8mm Жыл бұрын
aapke aashirwaad se mera package 15 crore ka lag jaayega 😌
@pratikshabakrola
@pratikshabakrola Жыл бұрын
My well wishes to you!
@KaifKhan-sb2yr
@KaifKhan-sb2yr 4 ай бұрын
Glt solution hai bhai 🫠
@princebhati6376
@princebhati6376 2 жыл бұрын
How do you get the job in usa, can u make a video about that.
@pratikshabakrola
@pratikshabakrola 2 жыл бұрын
Thank you for the suggestion. I will see if I can put something together on that subject, if I am not able to make a video, I will share some tips via email/call. You can follow my Facebook page and stay connected!
@princebhati6376
@princebhati6376 2 жыл бұрын
@@pratikshabakrola , i think linkedin would be better.
@pratikshabakrola
@pratikshabakrola 2 жыл бұрын
+Prince bhati Yes, I agree. That’s a great idea!
@thomasshelby6780
@thomasshelby6780 4 ай бұрын
wannabees be faking day and night
@EdgarRamirez-ry2je
@EdgarRamirez-ry2je 2 ай бұрын
You are beautiful
@RamyEldesoky
@RamyEldesoky 2 ай бұрын
This solution doesn't solve "()()"
@EdgarRamirez-ry2je
@EdgarRamirez-ry2je 2 ай бұрын
Hello do you have a boyfiend ???
@ManishRaj-zm5gs
@ManishRaj-zm5gs Жыл бұрын
galat hai
@pratikshabakrola
@pratikshabakrola Жыл бұрын
Feel free to share the code that you think is right for our viewers
@Karthik-ev7jy
@Karthik-ev7jy 10 ай бұрын
public class Solution { // DO NOT MODIFY THE ARGUMENTS WITH "final" PREFIX. IT IS READ ONLY public int solve(final String A) { Stack stack = new Stack(); int maxLen = 0; stack.push(-1); // Push -1 to represent the starting index for (int i = 0; i < A.length(); i++) { if (A.charAt(i) == '(') { stack.push(i); // Push the index of opening parenthesis } else { stack.pop(); // Pop the matching opening parenthesis index if (!stack.isEmpty()) { maxLen = Math.max(maxLen, i - stack.peek()); // Calculate length of valid substring } else { stack.push(i); // If no matching opening parenthesis found, push current index } } } return maxLen; } } @@pratikshabakrola
Median of Two Sorted Arrays leetcode
10:24
Pratiksha Bakrola
Рет қаралды 3,6 М.
Longest Valid Parentheses | Live Coding with Explanation | Leetcode - 32
12:51
Algorithms Made Easy
Рет қаралды 51 М.
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 51 МЛН
Why is everyone LYING?
7:56
NeetCodeIO
Рет қаралды 350 М.
LONGEST VALID PARENTHESIS | LEETCODE # 32 | PYTHON OPTIMAL SOLUTION
12:51
L11. Valid Parenthesis String | Multiple Approaches
26:09
take U forward
Рет қаралды 46 М.
Valid Parentheses | Leetcode
12:48
take U forward
Рет қаралды 201 М.
Leetcode - Longest Valid Parentheses (Python)
10:10
Timothy H Chang
Рет қаралды 10 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 577 М.
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 51 МЛН