Return all root-to-leaf path sums
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates competency in binary tree traversal and path-state accumulation, focusing on the ability to compute sums along root-to-leaf paths while handling edge cases like empty trees and negative values.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([5,[4,None,None],[8,[11,None,None],[4,None,None]]],)
Expected Output: [9, 24, 17]
Explanation: DFS root-to-leaf sums.
Input: ([-3,None,None],)
Expected Output: [-3]
Explanation: Single node path.
Input: (None,)
Expected Output: []
Explanation: Empty tree returns empty list.
Hints
- Clarify edge cases before coding.
- Keep the return value deterministic.