Balanced Brackets “{()}()” algorithm

This is a very common interview question and I personally faced it before on a technical phone interview with one of the top 5 tech companies in the world! The concept is easy but tricky. You need to use a stack and a HasMap to solve it. The stack is simply an array but you need to know what to store in it and how to pop items from it. The HasMap will store all the brackets and their adjacent matching closing vs opening brackets. So the idea is just to add a closing bracket when you see an opening bracket and when you see a closing bracket then you need to pop out a closing bracket from the stack. If at the end you see the stack is not empty then your string has a wrong brackets string.

So, what do you think ?