Last active
June 21, 2017 17:46
-
-
Save andreis/9c02400c243af4a1fd71726480b784d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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