2019-07-27 |

求两棵树是否相同

A
B
C
D
答案:
def isSameTree(p, q):
    if p == None and q == None:
        return True
    elif p and q :
        return p.val == q.val and isSameTree(p.left,q.left) and isSameTree(p.right,q.right)
    else :
        return False
解释:

0

剑指offer

发表评论

    评价:
    验证码: 点击我更换图片
    最新评论