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 Solvers1103
Suggested Problems
-
Count from 0 to N^M in base N.
234 Solvers
-
454 Solvers
-
Is my wife right? Now with even more wrong husband
1304 Solvers
-
Convert a numerical matrix into a cell array of strings
1241 Solvers
-
Flag largest magnitude swings as they occur
652 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!