Cody

Problem 1303. Is the paranthesis sequence balanced ?

Solution 450999

Submitted on 6 Jun 2014
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   Fail
assert(isequal(balance_parens('(((()))((())))'),1))

The function balance is a built-in MATLAB function. Please use a different function name.

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

The function balance is a built-in MATLAB function. Please use a different function name.

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

The function balance is a built-in MATLAB function. Please use a different function name.

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

The function balance is a built-in MATLAB function. Please use a different function name.

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

The function balance is a built-in MATLAB function. Please use a different function name.

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

The function balance is a built-in MATLAB function. Please use a different function name.

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

The function balance is a built-in MATLAB function. Please use a different function name.

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

The function balance is a built-in MATLAB function. Please use a different function name.

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!