0199. Binary Tree Right Side View

https://leetcode.com/problems/binary-tree-right-side-view

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.

Example 1:

Example 2:

Example 3:

Constraints:

  • The number of nodes in the tree is in the range [0, 100].

  • -100 <= Node.val <= 100

ac1: BFS

ac2: DFS

Last updated

Was this helpful?