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