Compute root-to-leaf number sum
Company: Bytedance
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates understanding of binary tree data structures and the competency to aggregate values along root-to-leaf paths, combining tree traversal with numeric accumulation of node digits.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([4,9,0,5,1],)
Expected Output: 1026
Explanation: Prompt example.
Input: ([],)
Expected Output: 0
Explanation: Empty tree.
Input: ([1,2,3],)
Expected Output: 25
Explanation: Two root-leaf numbers.
Hints
- Model object-style prompts as operation streams when needed.
- Handle empty and boundary cases before the main logic.