We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f39dbdc commit af81b5bCopy full SHA for af81b5b
src/0201-0300/226 - Invert Binary Tree/invert_binary_tree.go
@@ -0,0 +1,21 @@
1
+package main
2
+
3
+// Definition for a binary tree node.
4
+type TreeNode struct {
5
+ Val int
6
+ Left *TreeNode
7
+ Right *TreeNode
8
+}
9
10
+func invertTree(root *TreeNode) *TreeNode {
11
+ if root == nil {
12
+ return nil
13
+ }
14
15
+ invertTree(root.Left)
16
+ invertTree(root.Right)
17
18
+ root.Left, root.Right = root.Right, root.Left
19
20
+ return root
21
0 commit comments