|
| 1 | +<p>Given the <code>root</code> of a binary tree, imagine yourself standing on the <strong>right side</strong> of it, return <em>the values of the nodes you can see ordered from top to bottom</em>.</p> |
| 2 | + |
| 3 | +<p> </p> |
| 4 | +<p><strong class="example">Example 1:</strong></p> |
| 5 | + |
| 6 | +<div class="example-block"> |
| 7 | +<p><strong>Input:</strong> <span class="example-io">root = [1,2,3,null,5,null,4]</span></p> |
| 8 | + |
| 9 | +<p><strong>Output:</strong> <span class="example-io">[1,3,4]</span></p> |
| 10 | + |
| 11 | +<p><strong>Explanation:</strong></p> |
| 12 | + |
| 13 | +<p><img alt="" src="https://assets.leetcode.com/uploads/2024/11/24/tmpd5jn43fs-1.png" style="width: 400px; height: 207px;" /></p> |
| 14 | +</div> |
| 15 | + |
| 16 | +<p><strong class="example">Example 2:</strong></p> |
| 17 | + |
| 18 | +<div class="example-block"> |
| 19 | +<p><strong>Input:</strong> <span class="example-io">root = [1,2,3,4,null,null,null,5]</span></p> |
| 20 | + |
| 21 | +<p><strong>Output:</strong> <span class="example-io">[1,3,4,5]</span></p> |
| 22 | + |
| 23 | +<p><strong>Explanation:</strong></p> |
| 24 | + |
| 25 | +<p><img alt="" src="https://assets.leetcode.com/uploads/2024/11/24/tmpkpe40xeh-1.png" style="width: 400px; height: 214px;" /></p> |
| 26 | +</div> |
| 27 | + |
| 28 | +<p><strong class="example">Example 3:</strong></p> |
| 29 | + |
| 30 | +<div class="example-block"> |
| 31 | +<p><strong>Input:</strong> <span class="example-io">root = [1,null,3]</span></p> |
| 32 | + |
| 33 | +<p><strong>Output:</strong> <span class="example-io">[1,3]</span></p> |
| 34 | +</div> |
| 35 | + |
| 36 | +<p><strong class="example">Example 4:</strong></p> |
| 37 | + |
| 38 | +<div class="example-block"> |
| 39 | +<p><strong>Input:</strong> <span class="example-io">root = []</span></p> |
| 40 | + |
| 41 | +<p><strong>Output:</strong> <span class="example-io">[]</span></p> |
| 42 | +</div> |
| 43 | + |
| 44 | +<p> </p> |
| 45 | +<p><strong>Constraints:</strong></p> |
| 46 | + |
| 47 | +<ul> |
| 48 | + <li>The number of nodes in the tree is in the range <code>[0, 100]</code>.</li> |
| 49 | + <li><code>-100 <= Node.val <= 100</code></li> |
| 50 | +</ul> |
0 commit comments