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.
- Balanced Brackets
- Discussions
Balanced Brackets
Balanced Brackets
Sort by
recency
|
240 Discussions
|
Please Login in order to post a comment
My answer with Typescript.
Idea is remove couple of bracket when it can, then check remaining [s], if it empty mean it fully valid brackets
JavaScript Solution:-
My Python code works for most of the test cases, but is unable to finish within the time limits for some of the test cases. Can anyone help me optimize my code? It starts off by making sure that there is an even number of brackets. Next, if a pair of brackets are next to each other, they get removed. This is continued until there is nothing left, meaning that those brackets are balanced, or until nothing happens, meaning that those brackets are not balanced.
My Java solution:
This is my python solution. It's consise and self explanatory if you understand the application of a stack.