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 Solvers1079
Suggested Problems
-
Sum of first n terms of a harmonic progression
357 Solvers
-
878 Solvers
-
Implement simple rotation cypher
1031 Solvers
-
Split a string into chunks of specified length
1190 Solvers
-
The Answer to Life, the Universe, and Everything
477 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!