对称,就是左右相同,原理简单,需要理解,超简短代码
/* function TreeNode(x) {
    this.val = x;
    this.left = null;
    this.right = null;
} */
function isSymmetrical(pRoot) {
  // write code here :
  return !pRoot||fn(pRoot.left, pRoot.right);
}
function fn(a, b) {
  return  (!a && !b) || (a && b && a.val == b.val && fn(a.left, b.right) && fn(a.right, b.left)) ;
}
module.exports = {
  isSymmetrical: isSymmetrical,
};