1740. Find Distance in a Binary Tree
Last updated
Last updated
**Input:** root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 0
**Output:** 3
**Explanation:** There are 3 edges between 5 and 0: 5-3-1-0.**Input:** root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 7
**Output:** 2
**Explanation:** There are 2 edges between 5 and 7: 5-2-7.**Input:** root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 5
**Output:** 0
**Explanation:** The distance between a node and itself is 0.