8000 Feat:94 · FX-Max/leetcode@d6d6134 · GitHub
[go: up one dir, main page]

Skip to content

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)
0