Skip to content

Instantly share code, notes, and snippets.

@andreis

andreis/invbin.go

Last active Jun 21, 2017
Embed
What would you like to do?
// https://leetcode.com/problems/invert-binary-tree
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func invertTree(root *TreeNode) *TreeNode {
if root == nil {
return nil
}
root.Left, root.Right = invertTree(root.Right), invertTree(root.Left)
return root
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment