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
|
237 Discussions
|
Please Login in order to post a comment
My Java solution:
This is my python solution. It's consise and self explanatory if you understand the application of a stack.
JS solution:
Python solution:
My solution avoids to read types of brackets:
-opening brackets have even values
-closing brackets have odd values next to the corresponding opening bracket We then just need to check that an odd value doesn't fill an empty stack or that there is no even value in the stack different from the expected one.
C++ O(n)
the idea:
}(){
The code: