Problem 1303. Is the paranthesis sequence balanced ?
Quantum mechanics and computer science are interested in bra-kets. Today however you, the player, will have to write a function to find if the given parenthesis expression is balanced.
e.g.
>> balance('(()()())')
1
>> balance('(()()())(')
0
>> balance('(())))()())')
0
>> balance('(((()))((())))')
1
Solution Stats
Problem Comments
-
11 Comments
Show
8 older comments
Dyuman Joshi
on 30 Dec 2020
Similar to Problem 80
Robert Wagner
on 8 Nov 2023
Test 4 doesn't work
Christian Schröder
on 8 Nov 2023
@Robert what's wrong with test 4? ")(" isn't balanced - it's closing a parenthesis when none's open.
Solution Comments
Show commentsGroup

Matrix Manipulation I
- 16 Problems
- 98 Finishers
- Remove the air bubbles
- Remove NaN ?
- N-Dimensional Array Slice
- Back to basics 21 - Matrix replicating
- Back to basics 23 - Triangular matrix
- Make an awesome ramp for a tiny motorcycle stuntman
- Flip the main diagonal of a matrix
- surrounded matrix
- Some Assembly Required
- Set some matrix elements to zero
- Matrix with different incremental runs
- Removing rows from a matrix is easy - but what about inserting rows?
- Rotate input square matrix 90 degrees CCW without rot90
- Permute diagonal and antidiagonal
- Operate on matrices of unequal, yet similar, size
- Reverse the elements of an array
Problem Recent Solvers179
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!