-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
/**
* Definition for a binary tree node.
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @param {TreeNode} p
* @param {TreeNode} q
* @return {boolean}
*/
var isSameTree = function(p, q) {
if(p===null || q===null){
return p === q;
}
if(p.val == q.val){
return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
}else{
return false;
}
};
leetcode原题地址:https://leetcode-cn.com/problems/same-tree/description/