28 lines
440 B
Go
28 lines
440 B
Go
package top100liked
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// https://leetcode.cn/problems/invert-binary-tree/description/?envType=study-plan-v2&envId=top-100-liked
|
|
|
|
type TreeNode struct {
|
|
Val int
|
|
Left *TreeNode
|
|
Right *TreeNode
|
|
}
|
|
|
|
func invertTree(root *TreeNode) *TreeNode {
|
|
if root == nil {
|
|
return nil
|
|
}
|
|
root.Left, root.Right = root.Right, root.Left
|
|
invertTree(root.Left)
|
|
invertTree(root.Right)
|
|
return root
|
|
}
|
|
|
|
func Test1(t *testing.T) {
|
|
|
|
}
|