100. Same Tree
2016-08-02 本文已影响6人
oo上海
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)