class Solution {
public:
vector<vector<int>> res;
map<int,vector<int>> Map;
vector<vector<int>> verticalOrder(TreeNode* root) {
if(root==NULL) return res;
dfs(root,0);
map<int,vector<int>>::iterator it;
for(it=Map.begin();it!=Map.end();it++) {
res.push_back(it->second);
}
return res;
}
void dfs(TreeNode* f,int col) {
Map[col].push_back(f->val);
if(f->left) {
dfs(f->left,col-1);
}
if(f->right) {
dfs(f->right,col+1);
}
}
};