Update 二叉树的递归遍历.md

This commit is contained in:
jianghongcheng 2023-05-03 19:27:58 -05:00 committed by GitHub
parent dd58553088
commit dd1da7fc54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -191,7 +191,8 @@ class Solution:
return [root.val] + left + right return [root.val] + left + right
```
```python
# 中序遍历-递归-LC94_二叉树的中序遍历 # 中序遍历-递归-LC94_二叉树的中序遍历
class Solution: class Solution:
def inorderTraversal(self, root: TreeNode) -> List[int]: def inorderTraversal(self, root: TreeNode) -> List[int]:
@ -202,6 +203,9 @@ class Solution:
right = self.inorderTraversal(root.right) right = self.inorderTraversal(root.right)
return left + [root.val] + right return left + [root.val] + right
```
```python
# 后序遍历-递归-LC145_二叉树的后序遍历 # 后序遍历-递归-LC145_二叉树的后序遍历
class Solution: class Solution: