# Why expected result for input of {1,2} is 2? Shouldn't it be 1?

• Why expected result for input of {1,2} is 2? Shouldn't it be 1?

• The minimum depth is defined as the number of nodes along the shortest path from the root node down to the nearest leaf node.

• So in this case {1,2} root 1 itself has a leaf node. The answer should be 1, can you please explain how it is 2 ?

• the length of the root 1 to its leaf 2 is 2. And it is the only path.

• You only need to calculate depth of leaf nodes, leaf node means which both children are NULL. Here root is not leaf node, hence you should calculate depth of '2'

• It is indeed arguable whether the Minimum depth of binary tree {1,2} is 1 or 2, It depends on the way one define the depth, if you want the shortest distance to a null node, then the answer would be 1 else if you want the shortest distance to a null node whose sibling is also a null node, in which case the answer to Binary tree{1,2} would be 2.

• The path must start and end on distinct nodes. In other words, the root node is not considered a leaf node.

• i think the trick here is "leaf" node. it self is not null but it has both children null

• @1337c0d3r at least add some description and examples to the question to make this clear. right now its ambiguous.Its been 4 years and people are still visiting this thread says something it.

• Because in {1,2}, 2 is leaf, 1 is not leaf(1 has right child 2), so path is 2.

• This post is deleted!

• I still get confused.
If the {1,2} case resulted in depth 2, 1 whether the tree with only one root node would return null? cuz there is no leave at all...

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.