Write a method to recursively check whether an equation has a balanced number of
left and right parentheses and brackets - (including (,),[,],{,}
).
isBalanced("() [] ()") ==> true
isBalanced("([)]") ==> false
Stack
can be very helpful in solving this problem
indexOf(char)
method on the String
class useful. The Stack
class might come in handy as well!
public static boolean isBalanced(String input) { }
C
Java
Python