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
Hint: consider using a stack. Review your basic data structures for ideas.

Solution Stats

462 Solutions

198 Solvers

Last Solution submitted on Feb 02, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers198

Suggested Problems

More from this Author10

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!