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.
each time you encounter an opening bracket, push it to the stack.
each time you encounter a closing bracket, check if the opening bracket at the top of the stack matches the closing bracket, if so, pop the stack.
to prevent segmentation fault in case of encountring a closing bracket with an empty stack, simply return NO. this would for example here: }(){
Balanced Brackets
You are viewing a single comment's thread. Return to all comments →
C++ O(n)
the idea:
}(){
The code: