LCA of deepest leaves

Write codeHard30 min

Your task

Given a binary tree as a level-order array arr (null for missing), return the value of the lowest common ancestor of all the DEEPEST leaves (the leaves at maximum depth). If there is a single deepest leaf, it is its own answer. The tree is non-empty with distinct values. 1 <= node count <= 10000.

Examples

lca_deepest_leaves(arr: list[int]) -> int
Example 1
Inputlca_deepest_leaves([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4])
Output2