Friday, May 26, 2017

Brackets parsing using a stack implementation


Here is a classic brackets parsing problem. In this case we treat []{}()<> are treated as opening and closing brackets accordingly. Now the idea is to insert any bracket into a stack and pop it when we parse a closing bracket and then check whether the popped character is a corresponding opening bracket.

Here is the implementation below :

No comments:

Post a Comment