4 ms Beats 98.45%
\n# Code\njava []\nclass Solution {\n    public int minRectanglesToCoverPoints(int[][] points, int w) {\n        Arrays.sort(points,(a,b)->a[0]-b[0]); // sort a
\n# Code\n```java []\nclass Solution {\n    public int minRectanglesToCoverPoints(int[][] points, int w) {\n        Arrays.sort(points,(a,b)->a[0]-b[0]); // sort as per x-value\n        int count=0;\n        int ref=points[0][0]; // reference point (x1) --> if condition fails, we update it \n        for(int i=1;i<points.length;i++){\n            if(points[i][0]-ref>w){ // if x2-x1 > w\n                count++; //  till i-1 we get a rectangle\n                ref=points[i][0]; // update reference point and start new rectangle from here\n            }\n        }\n        return count+1; // last rectangle, as we do not get the break point inside for loop\n    }\n}\n```
['Java']