import adt.tree.TreeNode;
public class Q040_Vertical_Sum_in_a_given_Binary_Tree {
public static void main(String[] args) {
TreeNode root = Tree.tree1();
Map<Integer, ArrayList<TreeNode>> map = new TreeMap<Integer, ArrayList<TreeNode>>();
verticalSum(root, 0, map);
// print out the sums
for (Map.Entry<Integer, ArrayList<TreeNode>> entry : map.entrySet()) {
int sum = 0;
ArrayList<TreeNode> list = entry.getValue();
for (int i = 0; i < list.size(); i++) {
TreeNode node = list.get(i);
sum += node.val;
}
System.out.format("%d ", sum);
}