Simple Implementation with custom sorting and greedy approach
Code\ncpp []\nclass Solution {\npublic:\n    static bool cmp(const vector<int>& a, const vector<int>& b) \n    {\n        if (a[0] == b[0]) {\n            retur
# Code\n```cpp []\nclass Solution {\npublic:\n    static bool cmp(const vector<int>& a, const vector<int>& b) \n    {\n        if (a[0] == b[0]) {\n            return a[1] < b[1];\n        }\n        return a[0] < b[0];\n    }\n    int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n        sort(points.begin(), points.end(), cmp);\n        int cnt = 0;\n        int x1 = -1;\n        int y1 = -1;\n        int x2 = -1;\n        int y2 = -1;\n        for (int i = 0; i < points.size(); i++) {\n            bool cov = false;\n            if (points[i][0] >= x1 && points[i][0] <= x2 && points[i][1] >= y1 && points[i][1] <= y2) {\n                cov = true;\n            }\n\n            if (!cov) {\n                if (points[i][0] >= x1 && points[i][0] <= x2) {\n                    y2 = max(points[i][1], y2);\n                } else {\n                    x1 = points[i][0];\n                    y1 = 0;\n                    x2 = x1 + w;\n                    y2 = points[i][1];\n\n                    cnt++;\n                }\n            }\n        }\n        return cnt;\n    }\n};\n```
['C++']