JAVA code || Beats 100% java users
Approach\n1. Iterate through the points\n2. Calculate the start and end index of the current range\n3. Find the range of points that can be covered by a single 
# Approach\n1. Iterate through the points\n2. Calculate the start and end index of the current range\n3. Find the range of points that can be covered by a single rectangle\n4. Increment the number of rectangles needed\n5. Move to the next range of points\n6. Return the minimum number of rectangles needed\n\n# Code\n```\nclass Solution {\n    public int minRectanglesToCoverPoints(int[][] points, int w) {\n        Arrays.sort(points, (a, b) -> Integer.compare(a[0], b[0]));\n\n        int numRectangles = 0;\n        int n = points.length;\n        int i = 0;\n\n        while (i < n) {\n            int startX = points[i][0];\n            int endX = startX + w;\n\n            int j = i;\n            while (j < n && points[j][0] <= endX) {\n                j++;\n            }\n\n            numRectangles++;\n\n            i = j;\n        }\n\n        return numRectangles;\n    }\n}\n```\n![leetbilli.jpg](https://assets.leetcode.com/users/images/dd49bf95-f65d-440b-8b8a-ee4c27b4842b_1713024938.274636.jpeg)\n\n
['Sorting', 'Java']