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 Solvers1014
Suggested Problems
-
1984 Solvers
-
367 Solvers
-
Make an awesome ramp for a tiny motorcycle stuntman
414 Solvers
-
Determine the number of odd integers in a vector
547 Solvers
-
Side of an equilateral triangle
4219 Solvers
More from this Author95
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!