|
| 1 | +{ |
| 2 | + "problem_name": "binary_tree_right_side_view", |
| 3 | + "solution_class_name": "Solution", |
| 4 | + "problem_number": "199", |
| 5 | + "problem_title": "Binary Tree Right Side View", |
| 6 | + "difficulty": "Medium", |
| 7 | + "topics": "Tree, Depth-First Search, Breadth-First Search, Binary Tree", |
| 8 | + "tags": ["grind-75"], |
| 9 | + "readme_description": "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*.", |
| 10 | + "readme_examples": [ |
| 11 | + { |
| 12 | + "content": "\n\n```\nInput: root = [1,2,3,null,5,null,4]\nOutput: [1,3,4]\n```" |
| 13 | + }, |
| 14 | + { |
| 15 | + "content": "\n\n```\nInput: root = [1,2,3,4,null,null,null,5]\nOutput: [1,3,4,5]\n```" |
| 16 | + }, |
| 17 | + { "content": "```\nInput: root = [1,null,3]\nOutput: [1,3]\n```" }, |
| 18 | + { "content": "```\nInput: root = []\nOutput: []\n```" } |
| 19 | + ], |
| 20 | + "readme_constraints": "- The number of nodes in the tree is in the range `[0, 100]`.\n- `-100 <= Node.val <= 100`", |
| 21 | + "readme_additional": "", |
| 22 | + "solution_imports": "from leetcode_py import TreeNode", |
| 23 | + "solution_methods": [ |
| 24 | + { |
| 25 | + "name": "right_side_view", |
| 26 | + "parameters": "root: TreeNode[int] | None", |
| 27 | + "return_type": "list[int]", |
| 28 | + "dummy_return": "[]" |
| 29 | + } |
| 30 | + ], |
| 31 | + "test_imports": "import pytest\nfrom leetcode_py.test_utils import logged_test\nfrom leetcode_py import TreeNode\nfrom .solution import Solution", |
| 32 | + "test_class_name": "BinaryTreeRightSideView", |
| 33 | + "test_helper_methods": [ |
| 34 | + { "name": "setup_method", "parameters": "", "body": "self.solution = Solution()" } |
| 35 | + ], |
| 36 | + "test_methods": [ |
| 37 | + { |
| 38 | + "name": "test_right_side_view", |
| 39 | + "parametrize": "root_list, expected", |
| 40 | + "parametrize_typed": "root_list: list[int | None], expected: list[int]", |
| 41 | + "test_cases": "[([1, 2, 3, None, 5, None, 4], [1, 3, 4]), ([1, 2, 3, 4, None, None, None, 5], [1, 3, 4, 5]), ([1, None, 3], [1, 3]), ([], [])]", |
| 42 | + "body": "root = TreeNode.from_list(root_list)\nresult = self.solution.right_side_view(root)\nassert result == expected" |
| 43 | + } |
| 44 | + ], |
| 45 | + "playground_imports": "from solution import Solution\nfrom leetcode_py import TreeNode", |
| 46 | + "playground_test_case": "# Example test case\nroot_list: list[int | None] = [1, 2, 3, None, 5, None, 4]\nexpected = [1, 3, 4]", |
| 47 | + "playground_execution": "root = TreeNode.from_list(root_list)\nresult = Solution().right_side_view(root)\nresult", |
| 48 | + "playground_assertion": "assert result == expected" |
| 49 | +} |
0 commit comments