why are the test-case 3 and 4 failing ?
BALANCED PARENTHESIS Testcase 3 and 4 failing
Your test cases are failing because you are not considering the heterogeneous sequence of parenthesis i.e. the string containing different types of parenthesis.
example:
{[}]([)
expected output: No
Your Output: Yes
This is happening because your code checked for the first parenthesis i.e. { in this case.
Then, it calls balance1()
which only checks for the occurrence of either β{β or β}β and ignores the rest of the parenthesis.
hope, this would help.
if you still have a problem, feel free to ask.
else give a like, I wonβt mind.
I rectified the problem pointed out by you but still 1 testcase is failing
Use a single stack, rather using three different stacks.
Your code is printing βYesβ for ([)], while it is expected to return βNoβ.
The given string is not balanced.
Hope, this would help.