Balanced parenthesis

what should be the approach for this problem??

Hey @rksrajneeshsah
lgorithm:

  • Declare a character stack S.
  • Now traverse the expression string exp.
    1. If the current character is a starting bracket ( β€˜(β€˜ or β€˜{β€˜ or β€˜[β€˜ ) then push it to stack.
    2. If the current character is a closing bracket ( β€˜)’ or β€˜}’ or β€˜]’ ) then pop from stack and if the popped character is the matching starting bracket then fine else parenthesis are not balanced.
  • After complete traversal, if there is some starting bracket left in stack then β€œnot balanced”