Solution: height/level --> printLevel --> call printLevel for each level in rev


#1
public void storeLevel(TreeNode root, int level, List<Integer> levelElem) {
    if (root == null) return;
    if (level == 1) {
        // Base case
        levelElem.add(root.val);
    } else {
        // Revcursive case
        storeLevel(root.left, level - 1, levelElem);
        storeLevel(root.right, level - 1, levelElem);
    }
}

public int height(TreeNode root) {
    if (root == null) {
        return 0;
    } else {
        return Math.max(height(root.left), height(root.right)) + 1;
    }
}

public ArrayList<Integer> solve(TreeNode A) {
    ArrayList<Integer> res = new ArrayList<>();
    int level = height(A);
    //System.out.println("Level: " + level);
    for (int i = level; i >= 1; i--) {
        List<Integer> eachLevelElems = new ArrayList<>();
        storeLevel(A, i, eachLevelElems);
        res.addAll(eachLevelElems);
    }
    return res;
}