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
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
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