DFS variation is possible and can be somewhat simpler. The main difference is that you need to include the horizontal direction as the secondary ordering in the ordered (tree) map.

In other words, load the map as (col, row) coordinates during DFS. Then read out all the ordered map by column. Solution takes 3ms.

map<pair<int,int>, vector<int>> tmap; int colMin = 0, colMax = 0; void verticalOrder(TreeNode *node, int col, int lev) { colMin = min(colMin, col); colMax = max(colMax, col); tmap[make_pair(col, lev)].push_back(node->val); if (node->left) verticalOrder(node->left, col-1, lev+1); if (node->right) verticalOrder(node->right, col+1, lev+1); } vector<vector<int>> verticalOrder(TreeNode *root) { if (!root) return {}; verticalOrder(root, 0, 0); vector<vector<int>> res(colMax-colMin+1); for (auto t:tmap) { for (auto j:t.second) res[t.first.first - colMin].push_back(j); } return res; }