Java/Python Clean Solution || BiWeekly Context
Complexity\n- Time complexity:O(n+sorting)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n
# Complexity\n- Time complexity:$$O(n+sorting)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n**Java**\n```\nclass Solution {\n    public int minRectanglesToCoverPoints(int[][] points, int w) {\n        Arrays.sort(points, (a,b)->{\n            if(a[0]==b[0]){\n                return a[1]-b[1];\n            }\n            return a[0]-b[0];\n        });\n        \n        int rectangle =0;\n        int end =-1;\n        for(int[] point: points){\n            int x = point[0];\n            \n            if(x > end){\n                rectangle++;\n                end = x+w;\n            }\n        }\n        return rectangle;\n    }\n}\n```\n\n---\n\n\n**Python**\n```\nclass Solution:\n    def minRectanglesToCoverPoints(self, points: List[List[int]], w: int) -> int:\n        points.sort(key=lambda p:(p[0], p[1]))\n        \n        rectanges=0\n        last_end=-1\n        \n        for x,y in points:\n            if x> last_end:\n                rectanges+=1\n                last_end = x+w\n        return rectanges\n\n```
['Array', 'Sorting', 'Combinatorics', 'Python', 'Java', 'Python3']