Here is the interview question prompt, presented for reference.
A binary search tree
is a data structure that has the following properties,
- Each node in the tree has only two children.
- The left subtree consists of nodes with values less than the root node.
- The right subtree consists of nodes with values greater than the root node.
Consider a binary tree with the root node given as root
. Your task is to return the values of the nodes that are on the right side of the binary tree, ordered from top to bottom.
For example, consider the tree in the image above. On the right side of the tree, we see the values 9, 11, and 16. These are returned as an array [9, 11, 16]
.
100 <= Node.val <= 100
You can see the full challenge with visuals at this link.
Challenges • Asked about 2 years ago by Jake from AlgoDaily
This is the main discussion thread generated for Right Node View of Binary Tree (Main Thread).