Problem 80. Test for balanced parentheses
Solution Stats
Problem Comments
-
1 Comment
can be solved without 'regexp'
Solution Comments
-
1 Comment
A slightly more robust test might include a balanced equation starting with something other than an opening bracket.
Test 3 might be
inStr = '3*(z*(a-(x+3))/(y))';
-
1 Comment
Wrong solution.
-
2 Comments
it doesn't work in some cases not included in test suite. for example:
inStr = '(z*(a-(x+3))/(y)*z)';
Nice solution
-
1 Comment
Seems to fail for inStr='(' , '((', etc.
-
1 Comment
I admit this is cheating, but I think it also stresses the need for more tests in the suite. Also, not all the cases should necessarily be visible, so you can't adapt a solution like this.
-
1 Comment
This solution fails for the input ')()', i.e. it returns true when it should return false.
-
1 Comment
This solution fails for the input '(()', i.e. it returns true when it should return false.
-
1 Comment
This solution fails for the input '(()', i.e. it returns true when it should return false.
-
1 Comment
This entry is incorrect. It fails the simple case of:
isBalanced('(')
Problem Recent Solvers1104
Suggested Problems
-
628 Solvers
-
659 Solvers
-
954 Solvers
-
515 Solvers
-
Find out sum and carry of Binary adder
1010 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!