PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of binary tree data structures, including traversal strategies, mapping nodes to vertical columns, and computation of tree metrics such as diameter (measured in nodes), demonstrating competency in tree algorithms and positional indexing.

  • Medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Solve vertical order & diameter variants

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

##### Question LeetCode 314. Binary Tree Vertical Order Traversal LeetCode 543. Diameter of Binary Tree – modified to return the number of nodes (edges + 1) https://leetcode.com/problems/binary-tree-vertical-order-traversal/description/ https://leetcode.com/problems/diameter-of-binary-tree/description/

Quick Answer: This question evaluates understanding of binary tree data structures, including traversal strategies, mapping nodes to vertical columns, and computation of tree metrics such as diameter (measured in nodes), demonstrating competency in tree algorithms and positional indexing.

Given a binary tree in level-order array form using None for missing children, return both its vertical order traversal and its diameter measured in number of nodes. Vertical order groups nodes by their column index from leftmost to rightmost; within a column, nodes are listed from top to bottom, and when multiple nodes share the same row and column, they appear in left-to-right order. If the tree is empty, return an empty vertical list and diameter 0.

Constraints

  • 0 <= len(level) <= 10000
  • Values are integers in the range [-1e9, 1e9]
  • level[0] is not None unless the list is empty
  • Level-order uses None to indicate missing children; children of None are ignored
  • Output must be a dict: {"vertical": List[List[int]], "diameter": int}
  • Diameter is the number of nodes on the longest path; an empty tree has diameter 0

Hints

  1. Build the binary tree from the level-order list using a queue; ignore children of None entries.
  2. For vertical order, perform BFS while tracking each node's column index; append left child with col-1 and right child with col+1.
  3. For diameter in nodes, do a postorder traversal computing subtree heights and track max(left_height + right_height + 1).
Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)