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('(()()())') 1
>> balance('(()()())(') 0
>> balance('(())))()())') 0
>> balance('(((()))((())))') 1
Hint: consider using a stack. Review your basic data structures for ideas.
MATLAB and Simulink resources for Arduino, LEGO, and Raspberry PiLearn more
Opportunities for recent engineering grads.Apply Today
New to MATLAB?Learn MATLAB today!
Play games and win prizes!Learn more