2022-01-02(剑指 Offer 27. 二叉树的镜像)
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public TreeNode mirrorTree(TreeNode root) {
if(root==null){
return null;
}
TreeNode temp=mirrorTree(root.left);
root.left=mirrorTree(root.right);
root.right=temp;
共有 0 条评论