Using constant space.
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach : \nsort array on the basis of first index and the find difference of firs
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : \nsort array on the basis of first index and the find difference of first element of each array, whenever diff <= w ans++;\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O n(log(n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: constant\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n        ranges::sort(points, [](vector<int> a, vector<int> b){return a[0] < b[0];});\n        int ans = 1;\n        int n = points.size();\n        int i = 0, j = 0;\n        while(i < n-1 and j < n){\n            if(abs(points[i][0] - points[j][0]) >w) {\n                ans++;\n                i = j;\n            }\n            j++;\n        }\n        return ans;\n    }\n};\n```
['C++']