Grokking Meta Coding Interview
Ask Author
Back to course home

0% completed

Binary Tree Vertical Order Traversal (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given the root of the binary tree, return the 2D list containing the vertical order traversal of the binary tree.

A vertical order traversal of the tree is defined as a top to bottom, column by column traversal.

Note: If two nodes are in the same row and column, keep its order from left to right.

Examples

Example 1:

  • Input: A binary tree: [1,2,3,4,5,6,7]
  • Expected Output: [[4], [2], [1,5,6], [3], [7]]
  • Justification: Nodes 4, 2, 1 with 5 and 6, 3, and 7 are in separate vertical lines

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible