add new solutions
This commit is contained in:
parent
59b71480d4
commit
71189b61cf
8 changed files with 200 additions and 0 deletions
17
solutions/2/q226/solution.go
Normal file
17
solutions/2/q226/solution.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package q226
|
||||
|
||||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue