递归
条件:p1.val == p2.val && compare(p1.left,p2.right) && compare(p1.right,p2.left)
function isSymmetrical(pRoot)
{
function compare(p1,p2){
if(p1==null && p2==null)
return true;
if(p1==null || p2==null)
return false;
return p1.val == p2.val && compare(p1.left,p2.right) && compare(p1.right,p2.left);
}
if(pRoot == null)
return true;
return compare(pRoot.left,pRoot.right);
}
module.exports = {
isSymmetrical : isSymmetrical
};