#判断t1树是否包含t2树全部的拓扑结构
def isContain(t1, t2):
def check(t1, t2):
if not t2:
return True
if not t1 or t1.val != t2.val:
return False
return check(t1.left, t2.left) and check(t1.right, t2.right)
return check(t1, t2) or isContain(t1.left, t2) or isContain(t1.right, t2)
二叉树问题---判断t1树是否包含t2树全部的拓扑结构
最新推荐文章于 2022-01-16 10:32:26 发布