This video describes how to implement an application of Stack - Balanced Parentheses The following links are for reference: www.geeksforge... github.com/Shi...
This is more clear and better way. package com.rohit.demo; import java.util.ArrayDeque; import java.util.Deque; public class Balanced { public static boolean balanced(String exp) { Deque stack = new ArrayDeque(); for (int i = 0; i < exp.length(); i++) { char x = exp.charAt(i); if (x == '(' || x == '{' || x == '[') { stack.push(x); continue; } if(stack.isEmpty()) return false; stack.pop(); } if (stack.isEmpty()) return true; return false; } public static void main(String args[]) { String expr = "))(({}{"; System.out.println(balanced(expr)); } }
Plzzz do answer my question . that isMachingPare merhode is made by you ou it is predifend. if it is predefined then in which package . cuz I cant find it in Java.util package .
Everyone on youtube is literally explaining the procedure but very few of them focuses on explaining the code unfortunately according to me you are not one of them, you video ws not worth watching
Thanks in advance, now I am going to watch your video..
😃So nice OMG
This is more clear and better way.
package com.rohit.demo;
import java.util.ArrayDeque;
import java.util.Deque;
public class Balanced {
public static boolean balanced(String exp) {
Deque stack = new ArrayDeque();
for (int i = 0; i < exp.length(); i++) {
char x = exp.charAt(i);
if (x == '(' || x == '{' || x == '[') {
stack.push(x);
continue;
}
if(stack.isEmpty())
return false;
stack.pop();
}
if (stack.isEmpty())
return true;
return false;
}
public static void main(String args[]) {
String expr = "))(({}{";
System.out.println(balanced(expr));
}
}
Mam kamal ka ap ny samjhaya hai❤❤❤❤❤❤❤❤❤❤
You have tried your best but your explanation is not good one matching pair(st.pop().exp[i] what??
why do we return st.pop() as an argument of isMatchingPair function?
not clear about ismaching
???
7th line it should be (!st.empty()) i guess, as when the stack becomes empty it should return true, whereas here its false
nice shivangi
Code for matching function
Plzzz do answer my question . that isMachingPare merhode is made by you ou it is predifend. if it is predefined then in which package . cuz I cant find it in Java.util package .
it's in c++ .. It is a library you have to include #include
Mam make more videos on data structures plz
would you provide the code
2nd year??
Everyone on youtube is literally explaining the procedure but very few of them focuses on explaining the code unfortunately according to me you are not one of them, you video ws not worth watching