Find Maximum Path Sum in N-ary Tree
Company: Nuro
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
Overview: This question evaluates understanding of tree traversal and aggregation techniques, including handling of variable-arity nodes, negative values, and path-based dynamic programming on N-ary trees.
Constraints
- Tree is non-empty
Examples
Input: ([1, [[2, []], [3, [[5, []], [-6, []]]], [4, []]]],)
Expected Output: 13
Explanation: Prompt-style tree.
Input: ([-5, []],)
Expected Output: -5
Explanation: Single negative node.
Hints
- At each node, combine the top two nonnegative child gains for a path through that node.