Is the paranthesis sequence balanced ? - MATLAB Cody - MATLAB Central

Problem 1303. Is the paranthesis sequence balanced ?

Difficulty:Rate
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

47.69% Correct | 52.31% Incorrect
Last Solution submitted on May 03, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
3

Problem Recent Solvers182

Suggested Problems

More from this Author10

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page