Skip to content

104 maximum depth of binary tree

104. Maximum Depth of Binary Tree

题目: https://leetcode.com/problems/maximum-depth-of-binary-tree/

难度:

Easy

简单题,但是这道题跟leetcode111不一样,这道题没有特殊情况,所以一行就够了

class Solution(object):
    def maxDepth(self, root):
        """
        :type root: TreeNode
        :rtype: int
        """
        return 1 + max(map(self.maxDepth, (root.left, root.right))) if root else 0


回到顶部