rumtime error: munmap_chunk(): invalid pointer: 0x0000000002842c70 ***


  • 0

    If anyone can help me to identify why my code have run time error message :" munmap_chunk(): invalid pointer: 0x0000000002842c70 ***" when "submit solution", even though I do not have these errors when "run code" with the same test case.

    class Solution {
    public:
        
        static bool compare(Interval val1, Interval val2) {
            if (val1.start < val2.start)
                return true;
            else {
                if (val1.end < val2.end)
                    return true;
                else 
                    return false;
            }
        }
        
        int minMeetingRooms(vector<Interval>& intervals) {
            priority_queue<int, vector<int>, greater<int>> res;
            int len = intervals.size();
            int i;
            
            if (len == 0)
                return 0;
            
            sort(intervals.begin(), intervals.end(), compare);
            
            res.push(intervals[0].end);
            
            for (i = 1; i < len; i++) {
                if (intervals[i].start >= res.top()) {
                    res.pop();
                }
                res.push(intervals[i].end);
            }
                    
            return res.size();
        }
    };
    

Log in to reply
 

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