# Java solution with 2 vectors

• ``````/**
* Definition for a binary tree node.
* public class TreeNode {
*     int val;
*     TreeNode left;
*     TreeNode right;
*     TreeNode(int x) { val = x; }
* }
*/
import java.util.Vector;
public class Solution {
Vector<List<Integer>> negativeLists = new  Vector<List<Integer>>();
Vector<List<Integer>> positiveLists = new  Vector<List<Integer>>();

public List<List<Integer>> verticalOrder(TreeNode root) {
preOrderTraversal(root);
List<List<Integer>> result = new ArrayList<List<Integer>>();
for(int i = negativeLists.size()-1; i > 0; i--){
if(negativeLists.get(i) != null){
}
}
for(int i = 0; i < positiveLists.size(); i++) {
if(positiveLists.get(i) != null){
}
}
return result;
}

private static class IndexedNode {
public TreeNode node;
public int index;
public IndexedNode(){ }
public IndexedNode(TreeNode n, int i) {
node = n;
index = i;
}
}

private void preOrderTraversal(TreeNode node) {
if(node == null) {
return;
}
while(!queue.isEmpty()) {
IndexedNode n = queue.remove();
Vector<List<Integer>> vecLists = n.index < 0 ? negativeLists : positiveLists;
int i = Math.max(n.index, 0 - n.index);
while(vecLists.size() < i + 1){
}
if(vecLists.get(i) == null) {
vecLists.set(i, new ArrayList<Integer>());
}

if(n.node.left != null){