1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| var isSymmetric = function(root) { if(root === null){ return true; }else{ return helper(root.left , root.right); } };
function helper(p , q){ if( p === null && q ===null){ return true; } if( p === null || q ===null){ return false; } if( p.val != q.val){ return false; }else{ return helper(p.left, q.right) && helper(p.right , q.left); } }
|