From 600a42730c360df82e626ce91e27efc00342b310 Mon Sep 17 00:00:00 2001 From: jinbudaily <18336218010@163.com> Date: Fri, 21 Jul 2023 15:03:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=200111.=E4=BA=8C=E5=8F=89?= =?UTF-8?q?=E6=A0=91=E7=9A=84=E6=9C=80=E5=B0=8F=E6=B7=B1=E5=BA=A6=20?= =?UTF-8?q?=E6=8E=92=E7=89=88=E6=A0=BC=E5=BC=8F=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0111.二叉树的最小深度.md | 31 ++++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/problems/0111.二叉树的最小深度.md b/problems/0111.二叉树的最小深度.md index a1fc8a93..61f9beb7 100644 --- a/problems/0111.二叉树的最小深度.md +++ b/problems/0111.二叉树的最小深度.md @@ -26,9 +26,11 @@ 返回它的最小深度 2. -# 思路 +## 算法公开课 -《代码随想录》算法视频公开课:[看起来好像做过,一写就错! | LeetCode:111.二叉树的最小深度](https://www.bilibili.com/video/BV1QD4y1B7e2),相信结合视频在看本篇题解,更有助于大家对本题的理解。 +**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[看起来好像做过,一写就错! | LeetCode:111.二叉树的最小深度](https://www.bilibili.com/video/BV1QD4y1B7e2),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 + +## 思路 看完了这篇[104.二叉树的最大深度](https://programmercarl.com/0104.二叉树的最大深度.html),再来看看如何求最小深度。 @@ -52,7 +54,7 @@ 什么是叶子节点,左右孩子都为空的节点才是叶子节点! -## 递归法 +### 递归法 来来来,一起递归三部曲: @@ -199,7 +201,7 @@ public: }; ``` -## 迭代法 +### 迭代法 相对于[104.二叉树的最大深度](https://programmercarl.com/0104.二叉树的最大深度.html),本题还可以使用层序遍历的方式来解决,思路是一样的。 @@ -237,10 +239,10 @@ public: ``` -# 其他语言版本 +## 其他语言版本 -## Java +### Java: ```Java class Solution { @@ -300,7 +302,7 @@ class Solution { } ``` -## Python +### Python : 递归法(版本一) @@ -400,9 +402,7 @@ class Solution: return depth ``` - - -## Go +### Go: ```go /** @@ -463,7 +463,7 @@ func minDepth(root *TreeNode) int { ``` -## JavaScript +### JavaScript: 递归法: @@ -509,7 +509,7 @@ var minDepth = function(root) { }; ``` -## TypeScript +### TypeScript: > 递归法 @@ -547,7 +547,7 @@ function minDepth(root: TreeNode | null): number { }; ``` -## Swift +### Swift: > 递归 ```Swift @@ -594,7 +594,7 @@ func minDepth(_ root: TreeNode?) -> Int { ``` -## Scala +### Scala: 递归法: ```scala @@ -633,7 +633,8 @@ object Solution { } ``` -rust: +### Rust: + ```rust impl Solution { // 递归