题解 | #对称的二叉树#
对称的二叉树
http://www.nowcoder.com/practice/ff05d44dfdb04e1d83bdbdab320efbcb
请学会妙用check函数 使用arr的话 同样也是这个思想 根左右与跟右左
    this.val = x;
    this.left = null;
    this.right = null;
} */
function isSymmetrical(pRoot)
{
    // write code here
    // 队列想到了
    
    //怎么这种递归都要搞个check函数啊 
    if(!pRoot) return true
    return check(pRoot.left,pRoot.right)
    
  
    
}
function check(a,b){
    if(!a&&!b) return true
    if(a&&!b) return false
    if(!a&&b) return false
    if(a.val===b.val) return check(a.left,b.right)&&check(a.right,b.left)
}
module.exports = {
    isSymmetrical : isSymmetrical
};
 投递百度等公司10个岗位
投递百度等公司10个岗位

 
  网易游戏公司福利 555人发布
网易游戏公司福利 555人发布