🔥Beginner Approach - Consider only x - MinHeap | Clean Code | C++ |
Code\n\nclass Solution {\npublic:\n    int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n        priority_queue<int, vector<int>, greater<in
# Code\n```\nclass Solution {\npublic:\n    int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n        priority_queue<int, vector<int>, greater<int>> minHeap;\n        for (auto p : points)\n        {\n            minHeap.push(p[0]);\n        }\n\n        int prev = -1;\n        int res = 0;\n        while (!minHeap.empty())\n        {\n            prev = minHeap.top();\n            minHeap.pop();\n\n            while (minHeap.top() - prev <= w && !minHeap.empty())\n            {\n                minHeap.pop();\n            }\n            \n            res++;\n        }\n\n        return res;\n    }\n};\n```
['C++']