Leetcode 32 Longest Valid Parentheses

preview_player
Показать описание
Leetcode 32, Longest Valid Parentheses, 32. Longest Valid Parentheses, Leetcode 32. Longest Valid Parentheses, Leetcode Java Solution, Leetcode Java Solutions, Google Interview Question, amazon interview Question, Leetcode Java,Java solutions #Leetcode , #LeetcodeSolutions, #LeetcodeSolution #LeetcodeJavaSolutions #LeetcodeJavaSolution

Комментарии
Автор

One of the best Solution, Mam do the leetcode problems like this way its very help to us

allasandeep
Автор

Excellent solution, this one is more intutive, as compared to stack one.

kartikeyasingh
Автор

plz don't stop the way u explained so clearly and specify thankyou very much

nguyenbach
Автор

Your solution is very impressive . A like for you.

MR._NEEN
Автор

wasn't able to understand why two traversals : start to end and end to start, just understood, thanks bakrola mam

neetankumar
Автор

class Solution {
public int s) {

int left=0;
int right=0;
int max=0;

for(int i=0;i<s.length();i++)
{
if (s.charAt(i)=='(')
left++;
else
right++;
if(left==right)
{
max=Math.max(max, left*2);
}else if(right>left)
{
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;


}
}

pratikshabakrola
Автор

My approach was same but I was not doing checking in reverse direction, thanks

snehalmishra
Автор

great video, can you please make videos of graph questions ? Esp the ones that are not solved on other channels

holly_singh
Автор

Pratiksha explanation is too good also u are too cute 🥰

Area-fdht
Автор

Ma'am pls make videos on most important questions for sde role fresher

mohammedilyas
Автор

s =
")(", wrong for this input

satyamchoudhary
Автор

what if that would be a stack and they ask for thw range between indexes at longest parantheses

zeynepergul
Автор

Kind of feels like this solution is wrong

ShivangiSingh-wcgk
Автор

I think you should give proper explanation why another traversal is needed

gamerversez
Автор

class Solution {
public int s) {
int c=0;
for(int i=0;i<s.length()-1;i++){
if(s.charAt(i)=='(' && s.charAt(i+1)==')'){
c=c+2;
}
}
return c;
}

} why this code passess only 28 cases can anyone explain what i'm missing??

UnspokenTears
Автор

How do you get the job in usa, can u make a video about that.

princebhati