958. Check Completeness of a Binary Tree
Python
BFS
from collections import deque
class Solution:
def isCompleteTree(self, root: Optional[TreeNode]) -> bool:
queue = deque([root])
while queue:
node = queue.popleft()
if node:
queue.append(node.left)
queue.append(node.right)
continue
while queue:
if queue.popleft():
return False
return True