Desktop only
Coding Challenges are optimized for Desktop
Come back on a wider screen - the live editor needs room to breathe. You can still read the problem brief above.
Come back on a wider screen - the live editor needs room to breathe. You can still read the problem brief above.
tree = [1, [2, [4, [], []], [5, [], []]], [3, [], [6, [], []]]]
vertical_order(tree) # [[4], [2], [1, 5], [3], [6]] - within-column order not yet checkedtree = [1, [2, [], [7, [], []]], [4, [-5, [], []], []]]
# 7 is 2's right child (col 0, depth 2); -5 is 4's left child (col 0, depth 2).
# BFS expands 2 before 4, so 7 is discovered first.
vertical_order(tree) # [[2], [1, 7, -5], [4]]def vertical_order(tree: list, ties: str = "bfs") -> list[list[int]]: ...tree = [1, [2, [], [7, [], []]], [4, [-5, [], []], []]]
vertical_order(tree, ties="value") # [[2], [1, -5, 7], [4]]