LeetCode 226 Invert Binary Tree JAVA

来源:互联网 发布:java测试 博客园 编辑:程序博客网 时间:2024/06/05 01:19

这个比较逗,二叉树转置。

有一个故事,自己百度吧。

代码如下:


public class Solution {    public TreeNode invertTree(TreeNode root) {        if (root == null) return null;        TreeNode tmp = invertTree(root.left);        root.left = invertTree(root.right);        root.right = tmp;        return root;    }}


0 0