aboutsummaryrefslogtreecommitdiffstats
path: root/226/main.go
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2023-02-18 04:01:24 +0000
committerterminaldweller <thabogre@gmail.com>2023-02-18 04:01:24 +0000
commit49a72dcf24ba4f8d6b4f3beecc9e6d864fd8bb81 (patch)
treee696fcb6547cffee99630f0a551dd572ac585b2a /226/main.go
parent783 (diff)
downloadleetcode-49a72dcf24ba4f8d6b4f3beecc9e6d864fd8bb81.tar.gz
leetcode-49a72dcf24ba4f8d6b4f3beecc9e6d864fd8bb81.zip
226
Diffstat (limited to '')
-rw-r--r--226/main.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/226/main.go b/226/main.go
new file mode 100644
index 0000000..da66748
--- /dev/null
+++ b/226/main.go
@@ -0,0 +1,42 @@
+package main
+
+import "fmt"
+
+type TreeNode struct {
+ Val int
+ Left *TreeNode
+ Right *TreeNode
+}
+
+func invertTree(root *TreeNode) *TreeNode {
+ var invert func(root *TreeNode)
+ invert = func(root *TreeNode) {
+ if root == nil {
+ return
+ }
+
+ root.Left, root.Right = root.Right, root.Left
+ invert(root.Left)
+ invert(root.Right)
+ }
+ invert(root)
+
+ return root
+}
+
+// func invertTree(root *TreeNode) *TreeNode {
+// if root == nil {
+// return nil
+// }
+
+// right := invertTree(root.Right)
+// left := invertTree(root.Left)
+// root.Left = right
+// root.Right = left
+
+// return root
+// }
+
+func main() {
+ fmt.Println("vim-go")
+}