Distance between two nodes
Your task
Given a general binary tree as a level-order array arr (null for missing) and two distinct-or-equal values a and b that are both present, return the number of edges on the shortest path between them. If a == b the distance is 0. Values are distinct across the tree. 1 <= node count <= 20000.
Examples
distance_between_nodes(arr: list[int], a: int, b: int) -> intExample 1
Input
distance_between_nodes([1, 2, 3, 4, 5, 6, 7], 4, 7)Output
4