Cody

Problem 1303. Is the paranthesis sequence balanced ?

Solution 1902811

Submitted on 17 Aug 2019 by Nikolaos Nikolaou
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
assert(isequal(balance_parens('(((()))((())))'),1))

ans = logical 1

2   Pass
assert(isequal(balance_parens('(()()())'),1))

ans = logical 1

3   Pass
assert(isequal(balance_parens(['(()()()()()()()()()()()())']),1))

ans = logical 1

4   Pass
assert(isequal(balance_parens('(()()()))))'),0))

ans = logical 0

5   Pass
assert(isequal(balance_parens('(()()(((((((((((()))))'),0))

ans = logical 0

6   Pass
assert(isequal(balance_parens('))()())'),0))

ans = logical 0

7   Pass
assert(isequal(balance_parens('(()()()()((()))()()()(((()))))'),1))

ans = logical 1

8   Pass
assert(isequal(balance_parens('((((()))))'),1))

ans = logical 1

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!