You are viewing a single comment's thread. Return to all comments →
def height(root): queue = deque([root]) height = -1 while queue: level_len = len(queue) height += 1 for _ in range(level_len): current = queue.popleft() if current.left: queue.append(current.left) if current.right: queue.append(current.right) return height
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Height of a Binary Tree
You are viewing a single comment's thread. Return to all comments →