:orphan: Binary Tree Right Side View =========================== .. highlight:: none Problem ------- https://leetcode.com/problems/binary-tree-right-side-view/ Given the ``root`` of a binary tree, imagine yourself standing on the **right side** of it, return *the values of the nodes you can see ordered from top to bottom*.   **Example 1:** .. container:: example-block **Input:** root = [1,2,3,null,5,null,4] **Output:** [1,3,4] **Explanation:** |image1| **Example 2:** .. container:: example-block **Input:** root = [1,2,3,4,null,null,null,5] **Output:** [1,3,4,5] **Explanation:** |image2| **Example 3:** .. container:: example-block **Input:** root = [1,null,3] **Output:** [1,3] **Example 4:** .. container:: example-block **Input:** root = [] **Output:** []   **Constraints:** - The number of nodes in the tree is in the range ``[0, 100]``. - ``-100 <= Node.val <= 100`` .. |image1| image:: https://assets.leetcode.com/uploads/2024/11/24/tmpd5jn43fs-1.png .. |image2| image:: https://assets.leetcode.com/uploads/2024/11/24/tmpkpe40xeh-1.png .. highlight:: python Pattern ------- Tree, Depth-First Search, Breadth-First Search, Binary Tree Approaches ---------- .. tab-set:: .. tab-item:: BFS **Code** .. literalinclude:: ../problems/medium/binary-tree-right-side-view/binary_tree_right_side_view__bfs.py :language: python :lines: 11- **Test** >>> from binary_tree_right_side_view__bfs import rightSideView, TreeNode >>> rightSideView(TreeNode.from_list([1, 2, 3, None, 5, None, 4])) [1, 3, 4] >>> rightSideView(TreeNode.from_list([1, None, 3])) [1, 3] >>> rightSideView(None) [] .. autoclass:: binary_tree_right_side_view__bfs.TreeNode :members: :show-inheritance: :undoc-members: .. autofunction:: binary_tree_right_side_view__bfs.rightSideView