#-*- coding: UTF-8 -*-
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def maxDepth(self, root):
if root==None:return 0
leftDepth=self.maxDepth(root.left)
rightDepth=self.maxDepth(root.right)
return leftDepth+1 if leftDepth >rightDepth else (rightDepth+1)
相关文章
- 01-2630 Day Challenge Day 7 | Leetcode 235. Lowest Common Ancestor of a Binary Search Tree
- 01-26Python3解leetcode Lowest Common Ancestor of a Binary Search TreeBinary Tree Paths
- 01-26LeetCode-236 Lowest Common Ancestor of a Binary Tree
- 01-26LeetCode236. Lowest Common Ancestor of a Binary Tree(二叉树的最近公共祖先)
- 01-26Leetcode606.Construct String from Binary Tree根据二叉树创建字符串
- 01-26【Leetcode_easy】606. Construct String from Binary Tree
- 01-26LeetCode 606 Construct String from Binary Tree 解题报告
- 01-26【LeetCode】606. Construct String from Binary Tree 解题报告(Python)
- 01-26leetcode题解:Binary Tree Postorder Traversal (二叉树的后序遍历)
- 01-26LeetCode 145. Binary Tree Postorder Traversal二叉树的后序遍历 (C++)