104._maximum_depth_of_binary_tree.md 574 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11
### 104. Maximum Depth of Binary Tree

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


难度:

Easy


12
简单题,但是这道题跟[leetcode111](https://github.com/Lisanaaa/thinking_in_lc/blob/master/111._minimum_depth_of_binary_tree.md)不一样,这道题没有特殊情况,所以一行就够了
13 14 15


```python
K
KEQI HUANG 已提交
16 17 18 19 20 21
class Solution(object):
    def maxDepth(self, root):
        """
        :type root: TreeNode
        :rtype: int
        """
22
        return 1 + max(map(self.maxDepth, (root.left, root.right))) if root else 0
23
```