[Java/C++/Python] Sort + Greedy
Explanation\nSort points by x.\nIterate all points,\nif not coverd, res++,\nupdate the last that can cover.\n\n\n# Complexity\nTime O(sort)\nSpace O(sort)\n\n\n
# **Explanation**\nSort points by x.\nIterate all points,\nif not coverd, `res++`,\nupdate the `last` that can cover.\n<br>\n\n# **Complexity**\nTime `O(sort)`\nSpace `O(sort)`\n<br>\n\n**Java**\n```java\n    public int minRectanglesToCoverPoints(int[][] A, int w) {\n        Arrays.sort(A, (a, b)->a[0] - b[0]);\n        int res = 0, last = -1;\n        for (int[] a : A) {\n            if (a[0] > last) {\n                res++;\n                last = a[0] + w;\n            }\n        }\n        return res;\n    }\n```\n\n**C++**\n```cpp\n    int minRectanglesToCoverPoints(vector<vector<int>>& A, int w) {\n        sort(A.begin(), A.end());\n        int res = 0, last = -1;\n        for (auto& a: A)\n            if (a[0] > last)\n                res++, last = a[0] + w;\n        return res;\n    }\n```\n\n**Python**\n```py\n    def minRectanglesToCoverPoints(self, A: List[List[int]], w: int) -> int:\n        res = 0\n        last = -1\n        for x, y in sorted(A):\n            if x > last:\n                res += 1\n                last = x + w\n        return res\n```\n
['C', 'Python', 'Java']