FastPrepBinary Tree Right View
Problems/Binary Tree Right View

Binary Tree Right View

Pinecone logoPinecone● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Pinecone online assessment. The report names the right view of a binary tree. It does not give the interface, examples, or limits. Our version is about 94% the same as the reported question.

Given the root of a binary tree, imagine viewing the tree from its right side.

Return the value of the visible node at each depth, ordered from the root level downward. Return an empty array for an empty tree.

Function

rightSideView(root: TreeNode) → List<Integer>

Examples

Example 1

root = [1,2,3,null,5,null,4]return = [1,3,4]
root
12534

The rightmost values at successive depths are 1, 3, and 4.

Example 2

root = [1,null,3]return = [1,3]
root
13

The right child is visible below the root.

Example 3

root = []return = []
root
empty

An empty tree has no visible levels.

Constraints

  • The tree contains between 0 and 10000 nodes.
  • -10^9 <= Node.val <= 10^9.

More Pinecone Online Assessment questions

  • Minimum Binary String Length After Pair RemovalsOA · Seen Feb 2024
  • Set Matrix ZeroesOA · Seen Feb 2024
  • Tic-Tac-Toe Board StatusOA · Seen Feb 2024

Similar questions at other companies

  • Base Unit ConversionsAdobe · OAAdobe interview questions
  • Minimum-Sum Tree Fill with Unit StepsVisa · OAVisa interview questions
  • Minimum N-ary Tree Depth DeletionsSnowflake · OA · PHONE SCREENSnowflake interview questions
  • Tree Pythagorean TriplesIBM · OAIBM interview questions
  • Count LevelsBlackRock · OABlackRock interview questions
  • Maximum Data Transfer TimeMicrosoft · OAMicrosoft interview questions
  • Longest Transfer Time in a Server TreeRippling · OARippling interview questions
  • TikTok: Secondary InfluencersTikTok · OATikTok interview questions
  • Find Min Distance to Furthest Node (Google Tokyo)Google · OAGoogle interview questions
  • Binary Tree Level OrderMorgan Stanley · OAMorgan Stanley interview questions
See Pinecone hiring insights
Saved
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode() {}
 *     TreeNode(int val) { this.val = val; }
 *     TreeNode(int val, TreeNode left, TreeNode right) {
 *         this.val = val;
 *         this.left = left;
 *         this.right = right;
 *     }
 * }
 */
class Solution {
    public List<Integer> rightSideView(TreeNode root) {
        // Write your code here.
    }
}
Checking account…