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.
Since we can't use Python's collections.deque and the O(1) popleft function, it's actually more effecient to just maintain a pointer to your current location in the list (this avoids the O(N) cost of each pop(0) call).
Day 23: BST Level-Order Traversal
You are viewing a single comment's thread. Return to all comments →
Since we can't use Python's collections.deque and the O(1) popleft function, it's actually more effecient to just maintain a pointer to your current location in the list (this avoids the O(N) cost of each pop(0) call).
Python 3: