Test cases are not getting passed

https://ide.codingblocks.com/s/60438 for the problem balanced parenthesis two test cases are not getting passed.

Hey Simran , your logic for code is bit wrong . You have to check for the balance parenthesis ,which implies, for each closing bracket of type ) , } , ] you have to ensure that there must be a matching opening bracket ’ ( , { , [ , ’ on the top of stack , else that will not be balanced.
Your code will give correct output for following testcases -

  1. ( { ) }
  2. ((( )
    Try separating the if statements for all the closing brackets.
1 Like