File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/description/
2020 / \
2121 15 7
2222返回它的最大深度 3 。
23-
2423```
2524
2625## 前置知识
@@ -41,7 +40,8 @@ https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/description/
4140## 思路
4241
4342由于树是一种递归的数据结构,因此用递归去解决的时候往往非常容易,这道题恰巧也是如此,
44- 用递归实现的代码如下:
43+
44+ - 用递归实现的代码如下:
4545
4646``` js
4747var maxDepth = function (root ) {
@@ -57,16 +57,14 @@ var maxDepth = function (root) {
5757## 关键点解析
5858
5959- 队列
60-
6160- 队列中用 Null(一个特殊元素)来划分每层,或者在对每层进行迭代之前保存当前队列元素的个数(即当前层所含元素个数)
62-
6361- 树的基本操作- 遍历 - 层次遍历(BFS)
6462
6563## 代码
6664
67- - 语言支持:JS,C++,Java,Python
65+ - 语言支持:JS,C++,Java,Python, Go, PHP
6866
69- JavaScript Code:
67+ JS Code:
7068
7169``` js
7270/*
@@ -217,6 +215,7 @@ class Solution:
217215```
218216
219217Go Code:
218+
220219``` go
221220/* *
222221 * Definition for a binary tree node.
@@ -254,6 +253,7 @@ func maxDepth(root *TreeNode) int {
254253```
255254
256255PHP Code:
256+
257257``` php
258258/**
259259 * Definition for a binary tree node.
You can’t perform that action at this time.
0 commit comments