Update 0226.翻转二叉树.md

This commit is contained in:
QuinnDK 2021-05-12 21:01:01 +08:00 committed by GitHub
parent fbe43be1f4
commit 8fbfc3af8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -208,8 +208,21 @@ Java
Python
Go
```Go
func invertTree(root *TreeNode) *TreeNode {
if root ==nil{
return nil
}
temp:=root.Left
root.Left=root.Right
root.Right=temp
invertTree(root.Left)
invertTree(root.Right)
return root
}
```