function isSymmetrical(root)
{
if(!root) return true;
// 递归法
// return dfs(root.left,root.right);
// function dfs(left,right){
// if((!left && right)||(left && !right)) return false;
// if(!left && !right) return true;//这一行与后面一行不许颠倒
// if(left.val!==right.val) return false;
// let dfs_left=dfs(left.left,right.right);
// let dfs_right=dfs(left.right,right.left);
// return dfs_left && dfs_right;
// }
var queue=[root.left,root.right]
while(queue.length){
var leftNode=queue.shift();
var rightNode=queue.shift();
if(!leftNode && !rightNode) continue;
if(!leftNode || !rightNode || leftNode.val !=rightNode.val) return false;
queue.push(leftNode.left);
queue.push(rightNode.right);
queue.push(leftNode.right);
queue.push(rightNode.left);
}
return true;
}