I am so happy I came across your channel and I am surprised to see you don't have more likes on this video! This is the best explanation I've come across for solving this problem. I love how you draw out what the data structures look like at each iteration of the loop, and you use of color! I'm a visual learner so this was a huge help to me! :) I've subscribed and am looking forward to watching more of your videos! Thank you for this, it truly helped me out!
This was asked in HACKERRANK JAVA CERTIFICATION : Can you please explain me how this works ! Given a list of strings of bracket characters: {}(), the string of brackets is balanced under the following conditions:It is the empty string.If strings a and b are balanced, then ab is balanced.If string a is balanced, then (a) and {a} are balanced. Write a class that determines whether the brackets in each string are balanced and returns true if the string is balanced, or false if it is not. Example 0 s = [ "{}()", "{()}", "({()})" ] s[0] exhibits condition 2 above. "{}" and "()" are balanced, so "{}()" is balanced. Return true.s[1] exhibits condition 3 above. "()" is balanced, so "{()}" is balanced. Return true.s[2] exhibits condition 3 above. "()" is balanced, so "{()}" is balanced and "({()})" is balanced. Return true.
This problem is very much similar to the one I have discussed in the video. Each array element is a string that you need to check for balanced brackets.
@@rohitsaka it is exactly the same code, just start a for loop with each string in the array and call the function I have used. You should be able to solve it.
Hi Nikhil, before to watch your explanation I tried the stack method in javascript, I used a loop and switch method but I think I did something wrong because it didn´t work. However, in the very long strings, where you need a very large stack, should it work fine? I´ve used a counter too, like this: { 'A': 0, 'B': 0, 'C': 0} but you need to store the order too... so it doesn´t work. And, what happens if we need to exclude other characters, for example { a + ( b - C) * (a /c) }; we can´t check this except that we removes all characters !== ( || ) || [ || ] || { || } Have a nice day!
I am so happy I came across your channel and I am surprised to see you don't have more likes on this video! This is the best explanation I've come across for solving this problem. I love how you draw out what the data structures look like at each iteration of the loop, and you use of color! I'm a visual learner so this was a huge help to me! :) I've subscribed and am looking forward to watching more of your videos!
Thank you for this, it truly helped me out!
Really underrated channel! excellent explanation
Glad you like them!
2nd approach was like boom... nice explanation
Nice explanation 😊
Very clear explanation! i wish you best bro
so helpful, thank you so much
clear explanation ...thank u
Thank you sir. Nice explanation
Excellent explanation.
Loved it
This was asked in HACKERRANK JAVA CERTIFICATION :
Can you please explain me how this works !
Given a list of strings of bracket characters: {}(), the string of brackets is balanced under the following conditions:It is the empty string.If strings a and b are balanced, then ab is balanced.If string a is balanced, then (a) and {a} are balanced. Write a class that determines whether the brackets in each string are balanced and returns true if the string is balanced, or false if it is not. Example 0 s = [ "{}()", "{()}", "({()})" ] s[0] exhibits condition 2 above. "{}" and "()" are balanced, so "{}()" is balanced. Return true.s[1] exhibits condition 3 above. "()" is balanced, so "{()}" is balanced. Return true.s[2] exhibits condition 3 above. "()" is balanced, so "{()}" is balanced and "({()})" is balanced. Return true.
This problem is very much similar to the one I have discussed in the video. Each array element is a string that you need to check for balanced brackets.
@@nikoo28 can you please provide me solution if possible.
@@rohitsaka it is exactly the same code, just start a for loop with each string in the array and call the function I have used. You should be able to solve it.
2nd approch ❤
Hi Nikhil, before to watch your explanation I tried the stack method in javascript, I used a loop and switch method but I think I did something wrong because it didn´t work.
However, in the very long strings, where you need a very large stack, should it work fine?
I´ve used a counter too, like this:
{ 'A': 0, 'B': 0, 'C': 0}
but you need to store the order too... so it doesn´t work.
And, what happens if we need to exclude other characters, for example { a + ( b - C) * (a /c) }; we can´t check this except that we removes all characters !== ( || ) || [ || ] || { || }
Have a nice day!