Given an expression exp of length n consisting of some brackets. The task is to print the bracket numbers when the expression is being parsed
belongs to collection: Interview C++ coding problems/challenges | stack
All Answers
total answers (1)
belongs to collection: Interview C++ coding problems/challenges | stack
total answers (1)
So we actually need to parse the entire expression and whenever we are receiving an opening bracket we need to memorize its occurrence. So, we need a stack actually.
Pre-requisite:
String s – which is to be parsed
Algorithm:
Example with explanation:
C++ implementation:
Output