LeetCode 199, Medium . Topics: Tree , Depth-First Search , Breadth-First Search , Binary Tree . View on LeetCode .
Generate this problem as a practice environment: tested reference solution, 14 parametrized pytest cases , and a playground notebook:
Problem
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 .
Examples
Constraints
The number of nodes in the tree is in the range [0, 100].
-100 <= Node.val <= 100
Solution
Reference implementation from solution.py on GitHub , full suite in test_solution.py :
Complexity
Grind 75 , Grind , NeetCode 150 , NeetCode 250 , NeetCode All , AlgoMaster 75 .Last modified on September 7, 2026