class Stack { char[] toMatch; int topo; void push toMatch[topo] = class BalancedParentheses { Stack toMatch; static boolean hasBalancedParenteses (String s, int begin, int end) { if (begin>end) return True; else return matchingBalance(s,begin,end) || concatBalance{s,begin,end); } static matchingBalance(String s, int begin, int end) { push(s.charAt(begin)); topo++; if (hasBalancedParentheses(s, begin+1, end-1)) return match(toMatch,hasBalancedParentheses(s.charAt(end))); else return false; static concatBalance(String s, int begin, int end) { toMatch = s.charAt(begin); if (s.charAt(0) == '(' && s.charAt(s.length-1) = ')' and } } } class Main { public static void main (String[] args) { } }