题目介绍
给定一个二叉树,找出其最大深度。
+二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。
+说明: 叶子节点是指没有子节点的节点。
+示例:
给定二叉树 [3,9,20,null,null,15,7],
1 | 3 |
返回它的最大深度 3 。
+代码
1 | // 主体是个递归的应用 |
分析
其实对于树这类题,一般是以递归形式比较方便,只是要注意退出条件
+ +diff --git a/2014/12/23/my-new-post/index.html b/2014/12/23/my-new-post/index.html index f789020864..7d03191620 100644 --- a/2014/12/23/my-new-post/index.html +++ b/2014/12/23/my-new-post/index.html @@ -428,20 +428,20 @@
@@ -466,7 +466,7 @@ diff --git a/2014/12/24/MFC 模态对话框/index.html b/2014/12/24/MFC 模态对话框/index.html index 78ef20ffc7..bdefe8e42e 100644 --- a/2014/12/24/MFC 模态对话框/index.html +++ b/2014/12/24/MFC 模态对话框/index.html @@ -303,15 +303,15 @@