100. Same Tree
题目:
https://leetcode.com/problems/same-tree/
难度:
Easy
递归
class Solution(object):
def isSameTree(self, p, q):
"""
:type p: TreeNode
:type q: TreeNode
:rtype: bool
"""
if p == None or q == None:
if p == None and q == None:
return True
else:
return False
else:
return p.val == q.val and self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right)
网友评论