dfs
that takes a TreeNode and returns a list of distances of all leaf nodes to that node.null
, return an empty list.1
(distance from the leaf to itself).dfs
on the left and right children of the current node to get the list of distances from the left and right subtrees.distance
, increment a global count
variable.1
and add them to the new list.dfs
on the root node and return the global count
variable.