Vertical Order Traversal of a Binary Tree
CodingPhone ScreenSoftware EngineerReported Mar, 2026
Examples
Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: [[9],[3,15],[20],[7]]
Example 1:
Input: root = [3,9,20,null,null,15,7]
Output: [[9],[3,15],[20],[7]]
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.
1 <= number of nodes <= 10000 <= Node.val <= 1000Reported as LeetCode 987 in a software engineer phone screen.