When return value is "NO", you have should skipped the for loop.. example: (})() we found in the second index that it is not balanced..hence we need not check from third index to last
Tushar Goyal the pop happens before the actual check. We assign it to pop_val first then check it against the character that is seen in the string. Negative logic is used because we are only returning and stopping the run if our expectations of the character are not met
I've never seen anyone so happy before while coding
Nick looks like he is high on Hacker Rank
When return value is "NO", you have should skipped the for loop.. example:
(})()
we found in the second index that it is not balanced..hence we need not check from third index to last
Thank you!
It was a very optimistic solution...thanks!
you're a legend on hacker rank
Can someone tell me where the actual String with the brackets was declared? Where is its value ?I made a screenshot but I cannot see it.
Thank you Nick
Why does the leetcode solution fail one test case for this Hackerrank problem? Aren't they essentially the same problem?
Great explaination thanks a lott dude
thanks
amazing nick!!!
if the String passed is }}{{ then it will cause stack underflow because the code will try to pop out from the empty stack ?
Wrong if the stack is empty it will return NO in line 19-20
hey, small question.
you could also solve this by checking like if its a palindrome no?
No, because the string isn't necessarily symmetric
@@luisphilipeAn example please?
Well, I got it.
()(( )) is balanced but not a palindromic string. Thanks.
@@pranavnyavanandi9710 yeah, you got it. 💪
Could I do this using arraylist?
brother your pop operation is assigned as not equal to ,so how to pop the character when u return no
Tushar Goyal the pop happens before the actual check. We assign it to pop_val first then check it against the character that is seen in the string. Negative logic is used because we are only returning and stopping the run if our expectations of the character are not met
It would have been nice to return boolean. But yes or no is fine too. Thanks for the explanation 👍
The method needs to return a string
Stack stack = new Stack() does not work with node.js, can you tell me what line of code should I use instead of this one?.
Thank you.
let stack = [ ]
🥰 thanks for that
You are awesome!!
You should have a good night sleep bruh.. yh I know it's 2021 LoL