mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Update 0226.翻转二叉树.md
通过tmp显示交换的方式改为golang风格的交换
This commit is contained in:
@ -368,9 +368,7 @@ func invertTree(root *TreeNode) *TreeNode {
|
|||||||
if root ==nil{
|
if root ==nil{
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
temp:=root.Left
|
root.Left,root.Right=root.Right,root.Left//交换
|
||||||
root.Left=root.Right
|
|
||||||
root.Right=temp
|
|
||||||
|
|
||||||
invertTree(root.Left)
|
invertTree(root.Left)
|
||||||
invertTree(root.Right)
|
invertTree(root.Right)
|
||||||
|
Reference in New Issue
Block a user