|
| 1 | +<p>Given the <code>root</code> of a binary tree, return <em><strong>the vertical order traversal</strong> of its nodes' values</em>. (i.e., from top to bottom, column by column).</p> |
| 2 | + |
| 3 | +<p>If two nodes are in the same row and column, the order should be from <strong>left to right</strong>.</p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong class="example">Example 1:</strong></p> |
| 7 | +<img alt="" src="https://assets.leetcode.com/uploads/2024/09/23/image1.png" style="width: 400px; height: 273px;" /> |
| 8 | +<pre> |
| 9 | +<strong>Input:</strong> root = [3,9,20,null,null,15,7] |
| 10 | +<strong>Output:</strong> [[9],[3,15],[20],[7]] |
| 11 | +</pre> |
| 12 | + |
| 13 | +<p><strong class="example">Example 2:</strong></p> |
| 14 | +<img alt="" src="https://assets.leetcode.com/uploads/2024/09/23/image3.png" style="width: 450px; height: 285px;" /> |
| 15 | +<pre> |
| 16 | +<strong>Input:</strong> root = [3,9,8,4,0,1,7] |
| 17 | +<strong>Output:</strong> [[4],[9],[3,0,1],[8],[7]] |
| 18 | +</pre> |
| 19 | + |
| 20 | +<p><strong class="example">Example 3:</strong></p> |
| 21 | +<img alt="" src="https://assets.leetcode.com/uploads/2024/09/23/image2.png" style="width: 350px; height: 342px;" /> |
| 22 | +<pre> |
| 23 | +<strong>Input:</strong> root = [1,2,3,4,10,9,11,null,5,null,null,null,null,null,null,null,6] |
| 24 | +<strong>Output:</strong> [[4],[2,5],[1,10,9,6],[3],[11]] |
| 25 | +</pre> |
| 26 | + |
| 27 | +<p> </p> |
| 28 | +<p><strong>Constraints:</strong></p> |
| 29 | + |
| 30 | +<ul> |
| 31 | + <li>The number of nodes in the tree is in the range <code>[0, 100]</code>.</li> |
| 32 | + <li><code>-100 <= Node.val <= 100</code></li> |
| 33 | +</ul> |
0 commit comments