题解 | #判断是不是完全二叉树#
判断是不是完全二叉树
https://www.nowcoder.com/practice/8daa4dff9e36409abba2adbe413d6fae
class Solution:
def isCompleteTree(self , root: TreeNode) -> bool:
# write code here
list_temp2=[]#存结点
now=root
while now!=None:
list_temp2.append(now.left)
list_temp2.append(now.right)
if list_temp2:
now=list_temp2.pop(0)
if now==None:
for li in list_temp2:
if li!=None:
return False
else:
now=None
return True

