C++ | Beat 100% | Easiest Approach
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#include <vector>\n#include <climits>\n#include <algorithm>\nusing namespace std;\n\nclass Solution {\npublic:\n    int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n        sort(points.begin(), points.end()); \n        \n        int xmin = INT_MAX, xmax = INT_MIN;\n        int count = 0;\n        \n        for (int i = 0; i < points.size(); ++i) {\n            int x = points[i][0];\n            xmin = min(xmin, x);\n            xmax = max(xmax, x);\n            if (xmax - xmin > w) {\n                count++;\n                xmin = x;\n                xmax = x;\n            }\n        }\n        \n        return count + 1;\n    }\n};\n\n```
['C++']