Python Solution(Recursion)

  • 0

    class Solution(object):
    def minDepth(self, root):

        if root == None:
            return 0
        if root.left == None and root.right == None:
            return 1
        if root.left == None:
            return self.minDepth(root.right)+1
        if root.right == None:
            return self.minDepth(root.left)+1
        return min(self.minDepth(root.left),self.minDepth(root.right))+1


Log in to reply

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