226. Invert Binary Tree

Posted 阿怪123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了226. Invert Binary Tree相关的知识,希望对你有一定的参考价值。

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
public class Solution {
    public TreeNode invertTree(TreeNode root) {
        if(root==null)
            return null;
        TreeNode temp=root;
        TreeNode t=null;
        t=temp.left;
        temp.left=temp.right;
        temp.right=t;
        invertTree(temp.left);
        invertTree(temp.right);
        return temp;
    }
}

 

以上是关于226. Invert Binary Tree的主要内容,如果未能解决你的问题,请参考以下文章

226. Invert Binary Tree

letecode [226] - Invert Binary Tree

226. Invert Binary Tree

leetcode 226 Invert Binary Tree

226. Invert Binary Tree

#Leetcode# 226. Invert Binary Tree