Medium · Trees
Print vertical
Given the root of a binary tree, return its node values grouped by vertical column, from the leftmost column to the rightmost. The root is in column 0, and a left or right child is one column to the left or right of its parent. Within a column, list values from top to bottom, and list values in the same row from left to right.
Examples
Example 1
[3,9,20,null,null,15,7]Output: [9] [3,15] [20] [7]
Example 2
[1,2,3,4,5,6,7]Output: [4] [2] [1,5,6] [3] [7]
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.