Given the input inStr, give the boolean output out indicating whether all the parentheses are balanced.
Examples:
The string may include characters other than ( and ), but you should ignore them.
Incidentally, this problem was inspired from the Rosetta Code site. Why not create a few problems of your own by poking around the tasks at Rosetta Code?
can be solved without 'regexp'
Wrong solution.
it doesn't work in some cases not included in test suite. for example:
inStr = '(z*(a-(x+3))/(y)*z)';
Nice solution
Seems to fail for inStr='(' , '((', etc.
I admit this is cheating, but I think it also stresses the need for more tests in the suite. Also, not all the cases should necessarily be visible, so you can't adapt a solution like this.
This solution fails for the input ')()', i.e. it returns true when it should return false.
This solution fails for the input '(()', i.e. it returns true when it should return false.
This solution fails for the input '(()', i.e. it returns true when it should return false.
This entry is incorrect. It fails the simple case of:
isBalanced('(')
322 Solvers
Project Euler: Problem 10, Sum of Primes
534 Solvers
How long is the longest prime diagonal?
273 Solvers
Duplicate each element of a vector.
447 Solvers
Find out missing number from a vector of 9 elements
200 Solvers