What's wrong with this code ? Vertical Order Traversal of a Binary Tree

problem link : https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/
It's not passing the following test case :(
Wrong Answer
Details
Input
[0,2,1,3,null,null,null,4,5,null,7,6,null,10,8,11,9]
Output
[[4,10,11],[3,7,6],[2,5,8,9],[0],[1]]
Expected
[[4,10,11],[3,6,7],[2,5,8,9],[0],[1]]

Here is my code :

class Solution {
public:
    vector<vector<int>> verticalTraversal(TreeNode* root) {
        
         vector<vector<int>> output; 
        if(root==nullptr) return output;
        map<int,vector<int>> mp;
        queue<pair<TreeNode*,int>> q;
        q.push({root,0});
        while(!q.empty()){
            int qsize=q.size();
            for(int i=0;i<qsize;i++){ 
            TreeNode* curr=q.front().first;
            int hd=q.front().second;
            mp[hd].push_back(curr->val);
            q.pop();
            if(curr->left!=NULL) q.push({curr->left,hd-1});
            if(curr->right!=NULL) q.push({curr->right,hd+1});
            }
        }
        
        for(auto item : mp){
            auto x=item.second;
            output.push_back(x);
        }
        
        return output;
    }
Comments (1)