From 410dff4d908a4e992a2a3dc1d583706d684c04c2 Mon Sep 17 00:00:00 2001 From: XD <1296586920@qq.com> Date: Tue, 12 Mar 2024 13:18:06 +0800 Subject: [PATCH] =?UTF-8?q?Update=200104.=E4=BA=8C=E5=8F=89=E6=A0=91?= =?UTF-8?q?=E7=9A=84=E6=9C=80=E5=A4=A7=E6=B7=B1=E5=BA=A6=E4=B8=AD=E5=85=B3?= =?UTF-8?q?=E4=BA=8Esolution=E5=A4=A7=E5=B0=8F=E5=86=99=E9=97=AE=E9=A2=98.?= =?UTF-8?q?md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改了solution大小写问题,即solution改为Solution,力扣官网提交是需要大写的 --- problems/0104.二叉树的最大深度.md | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/problems/0104.二叉树的最大深度.md b/problems/0104.二叉树的最大深度.md index 1f55f197..12d56405 100644 --- a/problems/0104.二叉树的最大深度.md +++ b/problems/0104.二叉树的最大深度.md @@ -77,7 +77,7 @@ return depth; 所以整体c++代码如下: ```CPP -class solution { +class Solution { public: int getdepth(TreeNode* node) { if (node == NULL) return 0; @@ -94,7 +94,7 @@ public: 代码精简之后c++代码如下: ```CPP -class solution { +class Solution { public: int maxDepth(TreeNode* root) { if (root == null) return 0; @@ -110,7 +110,7 @@ public: 本题当然也可以使用前序,代码如下:(**充分表现出求深度回溯的过程**) ```CPP -class solution { +class Solution { public: int result; void getdepth(TreeNode* node, int depth) { @@ -144,7 +144,7 @@ public: 注意以上代码是为了把细节体现出来,简化一下代码如下: ```CPP -class solution { +class Solution { public: int result; void getdepth(TreeNode* node, int depth) { @@ -183,7 +183,7 @@ public: c++代码如下: ```CPP -class solution { +class Solution { public: int maxDepth(TreeNode* root) { if (root == NULL) return 0; @@ -232,7 +232,7 @@ public: c++代码: ```CPP -class solution { +class Solution { public: int maxDepth(Node* root) { if (root == 0) return 0; @@ -249,7 +249,7 @@ public: 依然是层序遍历,代码如下: ```CPP -class solution { +class Solution { public: int maxDepth(Node* root) { queue que; @@ -278,7 +278,7 @@ public: 104.二叉树的最大深度 ```java -class solution { +class Solution { /** * 递归法 */ @@ -319,7 +319,7 @@ class Solution { ``` ```java -class solution { +class Solution { /** * 迭代法,使用层序遍历 */ @@ -369,7 +369,7 @@ class Solution { ``` ```java -class solution { +class Solution { /** * 迭代法,使用层序遍历 */ @@ -402,7 +402,7 @@ class solution { 递归法: ```python -class solution: +class Solution: def maxdepth(self, root: treenode) -> int: return self.getdepth(root) @@ -417,7 +417,7 @@ class solution: 递归法:精简代码 ```python -class solution: +class Solution: def maxdepth(self, root: treenode) -> int: if not root: return 0