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.
-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.
Balanced Brackets
You are viewing a single comment's thread. Return to all comments →
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.