占用空间有点多。

import java.util.ArrayList;
/**
public class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;

    public TreeNode(int val) {
        this.val = val;

    }

}
*/
public class Solution {

    public ArrayList<Integer> PrintFromTopToBottom(TreeNode root) {
        ArrayList<Integer> res = new ArrayList<Integer>();
        if(root == null) return res;
        ArrayList<TreeNode> nodeque = new ArrayList<TreeNode>();
        nodeque.add(root);
        while(!nodeque.isEmpty()){
            TreeNode temp = nodeque.remove(0);
            res.add(temp.val);
            if(temp.left != null)   nodeque.add(temp.left);
            if(temp.right != null)  nodeque.add(temp.right);
        }
        return res;
    }

}