import java.util.ArrayList;
public class tmp1 {
public static void main(String[] args) {
TreeNode p1 =null;
}
public static int count = 0;
public static ArrayList<ArrayList<Integer>> row = new ArrayList<ArrayList<Integer>>();
public static ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) {
if (pRoot == null)
return row;
else {
depth(pRoot);
return row;
}
}
public static void depth(TreeNode pRoot) {
count++;
if (count > row.size()) {
ArrayList<Integer> al = new ArrayList<>();
row.add(al);
}
row.get(count - 1).add(pRoot.val);
if (pRoot.left != null)
depth(pRoot.left);
if (pRoot.right != null)
depth(pRoot.right);
count--;
}
public static class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
}
public class tmp1 {
public static void main(String[] args) {
TreeNode p1 =null;
}
public static int count = 0;
public static ArrayList<ArrayList<Integer>> row = new ArrayList<ArrayList<Integer>>();
public static ArrayList<ArrayList<Integer>> Print(TreeNode pRoot) {
if (pRoot == null)
return row;
else {
depth(pRoot);
return row;
}
}
public static void depth(TreeNode pRoot) {
count++;
if (count > row.size()) {
ArrayList<Integer> al = new ArrayList<>();
row.add(al);
}
row.get(count - 1).add(pRoot.val);
if (pRoot.left != null)
depth(pRoot.left);
if (pRoot.right != null)
depth(pRoot.right);
count--;
}
public static class TreeNode {
int val = 0;
TreeNode left = null;
TreeNode right = null;
public TreeNode(int val) {
this.val = val;
}
}
}