You are viewing a single comment's thread. Return to all comments →
Here's your stack...
import java.util.Stack; public class JavaStack { public static void main(String[] args){ Stack<String> stack = new Stack<>(); stack.push("{}()"); stack.push("({()})"); stack.push("{}("); stack.push("[]"); stack.forEach(element -> System.out.println(balancedString(element))); } private static boolean balancedString(String string){ while(string.length() != (string = string.replaceAll("\\(\\)|\\[\\]|\\{\\}", "")).length()); return (string.isEmpty()); } }
using stack here is dumb, its completely unnecessary
Seems like cookies are disabled on this browser, please enable them to open this website
Save the Prisoner!
You are viewing a single comment's thread. Return to all comments →
Here's your stack...
using stack here is dumb, its completely unnecessary