We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The thing to understand is that at any step, when a closing bracket is met, it must be a match for the last encountered opening bracket.
Using a stack to track expected next closing bracket does the job .
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Balanced Brackets
You are viewing a single comment's thread. Return to all comments →
The thing to understand is that at any step, when a closing bracket is met, it must be a match for the last encountered opening bracket. Using a stack to track expected next closing bracket does the job .