Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d6d6134

Browse files
committed
Feat:94
1 parent 793a151 commit d6d6134

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎problems/94-binary-tree-inorder-traversal.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## 题目
22

3+
* 94. 二叉树的中序遍历
4+
35
## 思路
46

57
## 代码
@@ -36,4 +38,22 @@ class Solution {
3638
return array_merge($left, $result, $right);
3739
}
3840
}
41+
42+
class Solution {
43+
44+
private $res = [];
45+
/**
46+
* @param TreeNode $root
47+
* @return Integer[]
48+
*/
49+
function inorderTraversal($root) {
50+
if (!$root) {
51+
return [];
52+
}
53+
$this->inorderTraversal($root->left);
54+
array_push($this->res, $root->val);
55+
$this->inorderTraversal($root->right);
56+
return $this->res;
57+
}
58+
}
3959
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /