阅读背景:

剑指offer - 面试思路

来源:互联网 

二叉树的镜像

操作给定的二叉树,将其变换为源二叉树的镜像。

/* function TreeNode(x) {
  this.val = x;
  this.left = null;
  this.right = null;
} */

function Mirror(root) {
  // write code here
  if (!root) {
    return;
  }
  [root.left, root.right] = [root.right, root.left];
  Mirror(root.left);
  Mirror(root.right);
  return root;
}
/* 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: