Sort the x value and use greedy approach
Intuition\nOnly the x value matters\n\n# Approach\nSort the x value and use greedy \n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n
# Intuition\nOnly the x value matters\n\n# Approach\nSort the x value and use greedy \n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    public int minRectanglesToCoverPoints(int[][] points, int w) {\n        List<Integer> xPoints = new ArrayList<>();\n        for (int[] point : points) {\n            xPoints.add(point[0]);\n        }\n        Collections.sort(xPoints);\n\n        int result = 0;\n        int rightBound = -1;\n        for (int i = 0; i < xPoints.size(); i++) {\n            if (xPoints.get(i) > rightBound) {\n                result++;\n                rightBound = xPoints.get(i) + w;\n            }\n        }\n        return result;\n    }\n}\n```
['Java']