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 Solvers1006
Suggested Problems
-
Number of 1s in the Binary Representation of a Number
386 Solvers
-
463 Solvers
-
Basics: 'Find the eigenvalues of given matrix
358 Solvers
-
Sum the numbers on the main diagonal
508 Solvers
-
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
370 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!