题目:
思路:递归
代码:
var isSubtree = function (s, t) {
if (!s) return false
if (isSub(s, t)) return true
return isSubtree(s.left, t) || isSubtree(s.right, t)
function isSub(treeS, treeT) {
if (!treeS && !treeT) return true
if (!treeS || !treeT) return false
if (treeT.val !== treeS.val) return false
return isSub(treeS.left, treeT.left) && isSub(treeS.right, treeT.right)
}
};
(ps:第四天)