Skip to content

Instantly share code, notes, and snippets.

@CollinShoop
Created January 23, 2022 03:54
Show Gist options
  • Save CollinShoop/960622a9abc95a1d7e1e5bedb16cd473 to your computer and use it in GitHub Desktop.
Save CollinShoop/960622a9abc95a1d7e1e5bedb16cd473 to your computer and use it in GitHub Desktop.
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func invertTree(root *TreeNode) *TreeNode {
if root == nil {
return root
}
root.Left, root.Right = root.Right, root.Left
invertTree(root.Left)
invertTree(root.Right)
return root
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment