Maximum path sum tree

Write codeHard30 minMeta style

Your task

Given a binary tree as a level-order array arr (using null for missing children, so JSON null arrives as Python None), find the maximum path sum. A path is any sequence of nodes connected by parent-child edges; it need not pass through the root and must contain at least one node. Node values may be negative. The tree is non-empty. 1 <= node count <= 30000.

Examples

max_path_sum(arr: list[int]) -> int
Example 1
Inputmax_path_sum([1, 2, 3])
Output6