Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
280 B
1
Indexable
Never
class Solution(object):
    def maxDepth(self, root):
        """
        :type root: TreeNode
        :rtype: int
        """
        def dfs(node):
            if node:
                return 1 + max(dfs(node.left), dfs(node.right))
            return 0
        return dfs(root)
Leave a Comment