mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 02:53:31 +08:00
Update 0226.翻转二叉树.md
This commit is contained in:
@ -208,8 +208,21 @@ Java:
|
|||||||
Python:
|
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
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user