Code Room
CodingHardcod-g547
Subject Binary treesLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a binary tree encoded as a level-order array (None marks a missing child; values may be negative), return the maximum path sum. A path is any sequence of nodes connected by edges where each node appears at most once; it does not need to pass through the root and need not be root-to-leaf. Use a post-order pass where each node returns the best downward gain (max single-branch contribution, clamped at 0) while a global best tracks the best 'arch' (left gain + node + right gain). Return the maximum path sum.

Implement
max_path_sum(level: list) → int
Examples
in[[-10,9,20,null,null,15,7]]out42
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.