← 返回 uber 的题目列表Vertical Order Traversal of a Binary Tree
类型:qbank
Given the root of a binary tree, sort its nodes by column from left to right. Nodes in the same column are ordered top to bottom by row, with ties on the same row and column broken by node value.
Vertical Order Traversal of a Binary Tree
Given the root of a binary tree, sort its nodes by column from left to right. Nodes in the same column are ordered top to bottom by row, with ties on the same row and column broken by node value.
SWE
tree
tree-traversal
bfs
sorting
hard
Frequency
Single report
Last asked
2026-03-21
Stage
phone-screen
Vertical Order Traversal of a Binary Tree
Given the root of a binary tree, sort its nodes by column from left to right. Nodes in the same column are ordered by row from top to bottom, and ties on the same row and column are broken by node value.
Examples
Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: [[9],[3,15],[20],[7]]
Constraints
1 <= number of nodes <= 1000
0 <= Node.val <= 1000