Time Complexity: O(n) and Space complexity: O(1)
Intuition\nSimple brute force\n\n# Approach\n1) Sort the coordinates according to the first coordinate of points in increasing order.\n2) Use the start variable
# Intuition\nSimple brute force\n\n# Approach\n1) Sort the coordinates according to the first coordinate of points in increasing order.\n2) Use the start variable to keep track of the index of the new rectangle each time it\'s encountered.\n3) ans stores the number of rectangles needed.\n4) In the while loop, calculate the end x-coordinate of the rectangle each time and check whether the x-coordinate of the current point is smaller than the end coordinate. \n5) If yes, then that point will come under that rectangle, and i is incremented.\n6) If no, then set start to i, and increment ans.\nOutside the loop, return ans.\n\n\n\n\n\n\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n# Code\n```\nclass Solution {\npublic:\n    typedef pair<int,int> pa;\n    static bool comp(vector<int>& v1, vector<int>& v2) {\n    return v1[0] < v2[0];\n    }\n\n    int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n        sort(points.begin(),points.end(),comp);\n        int n=points.size();\n        int ans=0;\n        int i=0;\n        int start=i;\n        while(i<n)\n        {\n            int end=points[start][0]+w;\n            if(points[i][0]<=end) i++;\n            else\n            {\n               start=i;\n               ans++;\n            }\n        }\n        return ans+1;\n    }\n};\n```
['C++']