今天的题目是100. 相同的树
递归
# p and q are both None
if not p and not q:
return True
# one of p and q is None
if not q or not p:
return False
if p.val != q.val:
return False
return self.isSameTree(p.right, q.right) and \
self.isSameTree(p.left, q.left)
执行用时 :28 ms, 在所有 Python3 提交中击败了93.09%的用户
内存消耗 :13.6 MB, 在所有 Python3 提交中击败了5.00%的用户