public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) {
ArrayList<Integer> reslist=
new ArrayList<>();
if(root==
null)
return reslist ;
// if(root.left==null&&root.right==null)return null;
Queue<TreeNode> curList=
new LinkedList<>();
Queue<TreeNode> nextList=
new LinkedList<>();
curList.add(root);
while (!curList.isEmpty()){
while (!curList.isEmpty()){
TreeNode tmpnode=curList.poll();
reslist.add(tmpnode.
val);
if(tmpnode.
left!=
null)nextList.add(tmpnode.
left);
if(tmpnode.
right!=
null)nextList.add(tmpnode.
right);
}
curList=nextList;
nextList=
new LinkedList<>();
}
return reslist;
}