Cody

Problem 1303. Is the paranthesis sequence balanced ?

Solution 1039386

Submitted on 31 Oct 2016
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.

Community Treasure Hunt

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

Start Hunting!