FastPrepVertical Tree Traversal with Value Ties
Problems/Vertical Tree Traversal with Value Ties

Vertical Tree Traversal with Value Ties

Meta logoMeta● HardINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The Meta ML PhD intern report links Vertical Order Traversal of a Binary Tree and says this question was explained verbally. Its linked statement gives coordinate ordering, ascending value ties, examples and bounds. Approximate source match: 100%.

Return the vertical traversal of a binary tree. The root is at (row,column) = (0,0). A left child moves to (row+1,column-1), and a right child to (row+1,column+1).

Return columns from leftmost to rightmost. Within a column, order nodes by increasing row. When multiple nodes share both row and column, order their values increasingly.

Function

verticalTraversal(root: TreeNode) → List<List<Integer>>

Examples

Example 1

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

Columns appear from leftmost to rightmost, with row order inside each column.

Example 2

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

Values 5 and 6 share row and column, so 5 comes first.

Example 3

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

Swapping the two shared-coordinate nodes does not change their sorted output.

Constraints

  • The tree contains between 1 and 1000 nodes.
  • 0 <= Node.val <= 1000.

More Meta Phone Screen questions

  • Convert a Sorted Linked List to a Balanced BSTPHONE SCREEN · Seen Nov 2026
  • Fuzzy Word Lookup With One Misspelled LetterPHONE SCREEN · Seen Nov 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Recursive Display SortFigma · PHONE SCREEN · ONSITE INTERVIEWFigma interview questions
  • Analyze Underpaid Managers in a Salary TreeGoogle · PHONE SCREENGoogle interview questions
  • Vertical Order Traversal of a Binary TreeBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Find All Paths for a Name in a File SystemThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Merge N-Ary Trees by KeyLinkedIn · PHONE SCREEN · ONSITE INTERVIEWLinkedIn interview questions
  • Filesystem Hash TreeCursor · PHONE SCREEN · ONSITE INTERVIEWCursor interview questions
  • Aggregate Machine TopologyOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Build a Trace ForestDatadog · PHONE SCREENDatadog interview questions
  • Print All File and Folder PathsNutanix · PHONE SCREENNutanix interview questions
  • Vertical Order Traversal of a Binary TreeTokopedia · ONSITE INTERVIEWTokopedia interview questions

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta 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<List<Integer>> verticalTraversal(TreeNode root) {
        // Write your code here
    }
}
Checking account…