跟这题一样的 https://blog.nowcoder.net/n/4012546b98ae4356ab926184ed323c58
import java.util.*;
public class Solution {
public boolean isCompleteTree (TreeNode root) {
if (root == null) return false;
Queue<TreeNode> q = new LinkedList<>();
q.offer(root);
boolean ended = false;
while(!q.isEmpty()) {
TreeNode pop = q.poll();
if (pop == null) {
ended = true;
} else {
if (ended) return false;
q.offer(pop.left);
q.offer(pop.right);
}
}
return true;
}
}