Implement BST vertical traversal and list conversion
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency with binary search trees, vertical-order traversal semantics, in-place pointer manipulation for converting a BST into a sorted doubly linked list, and algorithmic complexity analysis within the Coding & Algorithms domain.
BST Vertical Order Traversal
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([5,3,7,2,4,6,8],)
Expected Output: [[2], [3], [5, 4, 6], [7], [8]]
Explanation: Balanced BST.
Input: ([],)
Expected Output: []
Explanation: Empty tree.
Input: ([5,3,None,2],)
Expected Output: [[2], [3], [5]]
Explanation: Left-skewed partial tree.
Hints
- Choose a representation that makes the requested operation direct.
- Handle empty inputs and boundary cases first.
BST to Sorted Doubly Linked List Values
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([5,3,7,2,4,6,8],)
Expected Output: [2, 3, 4, 5, 6, 7, 8]
Explanation: Sorted in-order list.
Input: ([1],)
Expected Output: [1]
Explanation: Single node.
Input: ([],)
Expected Output: []
Explanation: Empty tree.
Hints
- Choose a representation that makes the requested operation direct.
- Handle empty inputs and boundary cases first.