Simplest Approach || Two Pointers || Sort
Intuition\nThe goal is to find the minimum number of rectangles needed to cover a set of points horizontally, where each rectangle has a specified width w.\n De
# Intuition\nThe goal is to find the minimum number of rectangles needed to cover a set of points horizontally, where each rectangle has a specified width w.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\ni) Identify points,\nii) sort x-coordinates,\niii) find intervals wider than width w, count rectangles needed.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n log(n))\n\n- Space complexity: O(n)\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        \n        vector<int> x;\n        for(int i=0; i<points.size(); i++)\n        {\n            x.push_back(points[i][0]);\n        }\n        \n        sort(x.begin(), x.end());\n        \n        int e=0, s=0;\n        int ans=1;\n    \n        while(e<x.size())\n        {\n            if(x[e]-x[s] > w)\n            {\n                ans++;\n                s=e;\n            }\n            e++;\n        }\n        return ans; \n    }\n};\n```
['Array', 'Two Pointers', 'Sorting', 'C++']