FastPrepBinary Tree Vertical Order Traversal
Problems/Binary Tree Vertical Order Traversal

Binary Tree Vertical Order Traversal

Google logoGoogle● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand report from a Google Software Engineer internship in the 2026 recruiting season names vertical order traversal of trees. The report does not give how the tree is passed in, how to order nodes at the same position, what to return for an empty tree, or the input limits. We filled those in the usual way. Our version is about 90% the same as the reported question.

Given the root of a binary tree, return its vertical order traversal.

Place the root in column 0. A left child is one column to the left of its parent, and a right child is one column to the right. Return the columns from leftmost to rightmost.

Within each column, list nodes from top to bottom. If two nodes have the same row and column, preserve their left-to-right breadth-first encounter order.

Function

verticalOrder(root: TreeNode) → int[][]

Examples

Example 1

root = [3,9,20,null,null,15,7]return = [[9],[3,15],[20],[7]]
root
3920157

The occupied columns are -1, 0, 1, and 2. Nodes 3 and 15 share column 0 and appear from top to bottom.

Example 2

root = [1,2,3,4,5,6,7]return = [[4],[2],[1,5,6],[3],[7]]
root
1245367

Nodes 5 and 6 have the same row and column. Breadth-first left-to-right order places 5 before 6.

Example 3

root = []return = []
root
empty

An empty tree has no columns.

Constraints

  • The tree contains at most 1000 nodes.
  • -1000 <= Node.val <= 1000.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Vertical Order Traversal of a Binary TreeAmazon · ONSITE INTERVIEW
  • Binary Tree Vertical Order TraversalBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Group Identical Tree LevelsSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Top-Down Employee Reporting ForestOkta · ONSITE INTERVIEWOkta interview questions
  • Merge N-Ary Trees by KeyLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Filesystem Hash TreeCursor · PHONE SCREEN · ONSITE INTERVIEWCursor interview questions
  • Bottom View of a Binary TreeOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
  • Binary Tree Vertical Order with Stable TiesMeta · ONSITE INTERVIEWMeta interview questions

Interview reports that mention this question

  • Google SWE Intern OA and Interviews: 42 Experiences (Part 1 of 3)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google 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 int[][] verticalOrder(TreeNode root) {
        // Write your code here.
    }
}
Checking account…