Runtime Error : reference binding to null pointer of type 'struct pair'


  • 0
    T

    Last executed input:
    [[8,2],[4,2],[4,5],[2,0],[7,2],[1,4],[9,1],[3,1],[9,0],[1,0]]

    For the above input, I am getting Runtime Error. Van anyone please point out as ot why this is happening ??
    Here's my code :

    class Solution 
    {
    public:
        vector<pair<int, int>> reconstructQueue(vector<pair<int, int>>& people) 
        {
            int i,a;
            vector<pair<int,int> > temp,res;
            map<int,vector<int> > mp;
            map<int,vector<int> >::reverse_iterator rit;
            for(i=0;i<people.size();i++)
                mp[people[i].first].push_back(people[i].second);
            for(rit=mp.rbegin();rit!=mp.rend();rit++)
            {
                temp.clear();
                for(i=0;i<(rit->second).size();i++)
                    temp.push_back({rit->first,(rit->second)[i]});
                for(i=0;i<temp.size();i++)
                    res.insert(res.begin()+temp[i].second,temp[i]);
            }
            return res;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.