A golang soultion


  • 0
    N
    func invertTree(root *TreeNode) *TreeNode {
    	if root != nil {
    		root.Left, root.Right = root.Right, root.Left
    		invertTree(root.Left)
    		invertTree(root.Right)
    	}
    	return root
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.