LeetCode: Invert Binary Tree

 1 /**
 2  * Definition for a binary tree node.
 3  * public class TreeNode {
 4  *     int val;
 5  *     TreeNode left;
 6  *     TreeNode right;
 7  *     TreeNode(int x) { val = x; }
 8  * }
 9  */
10 public class Solution {
11     public TreeNode invertTree(TreeNode root) {
12         if (root == null) return null;
13         TreeNode tmp = root.left;
14         root.left = invertTree(root.right);
15         root.right = invertTree(tmp);
16         return root;
17     }
18 }
原文地址:https://www.cnblogs.com/yingzhongwen/p/6097878.html