```
class Solution(object):
def minDepth(self, root):
if not root:
return 0
depth, level =1, [root]
while level :
netLevel=[]
for n in level :
if not n.left and not n.right :
return depth
if n.left:
netLevel.append(n.left)
if n.right:
netLevel.append(n.right)
depth+=1
level = netLevel
```