添加新题目
This commit is contained in:
20
二叉树/翻转二叉树/main.go
Normal file
20
二叉树/翻转二叉树/main.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
type TreeNode struct {
|
||||
Val int
|
||||
Left *TreeNode
|
||||
Right *TreeNode
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
func invertTree(root *TreeNode) *TreeNode {
|
||||
if root == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
root.Left, root.Right = invertTree(root.Left), invertTree(root.Right)
|
||||
root.Left, root.Right = root.Right, root.Left
|
||||
return root
|
||||
}
|
||||
Reference in New Issue
Block a user