Problem 80. Test for balanced parentheses
Given the input inStr, give the boolean output out indicating whether all the parentheses are balanced.
Examples:
- If inStr is '(()', the output is false.
- If inStr is '(xyz)(ab)' the output is true.
- If inStr is ')(', the output is false.
The string may include characters other than ( and ), but you should ignore them.
Incidentally, this problem was inspired from the Rosetta Code site. Why not create a few problems of your own by poking around the tasks at Rosetta Code?
Solution Stats
Problem Comments
-
1 Comment
Sanzhar Askaruly
on 13 Jul 2019
can be solved without 'regexp'
Solution Comments
Show commentsProblem Recent Solvers1218
Suggested Problems
-
Remove any row in which a NaN appears
8549 Solvers
-
1921 Solvers
-
How to find the position of an element in a vector without using the find function
2706 Solvers
-
696 Solvers
-
Who is the smartest MATLAB programmer?
744 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!