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.


>> balance('(()()())')
>> balance('(()()())(') 
>> balance('(())))()())')
>> balance('(((()))((())))')

Hint: consider using a stack. Review your basic data structures for ideas.

Solution Stats

67.92% Correct | 32.08% Incorrect
Last solution submitted on Oct 31, 2016
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more