Maximum path sum tree
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]) -> intExample 1
Input
max_path_sum([1, 2, 3])Output
6