Simple one loop
Intuition\n Describe your first thoughts on how to solve this problem. \nThe only limit is the width of rectangle(x2 - x1 <= w) and the height can be any value.
### Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe only limit is the width of rectangle(`x2 - x1 <= w`) and the height can be any value.\n\n### Approach\n<!-- Describe your approach to solving the problem. -->\nWe can ignore the `y` of point since the height can be any value.\n\n1. Convert two dimension problem to one dimension.\n1. Focus on `x`, we want to cover all `x` with `w` width rectangle.\n1. We should cover the `x` point with largest width `w` greedy.\n1. Sort the points with the `x` value.\n1. Only add rectangle when the `x` out of the threshold.\n\n### Complexity\n- Time complexity: $$O(N*logN)$$\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```\nclass Solution {\n  public int minRectanglesToCoverPoints(int[][] points, int w) {\n    Arrays.sort(points, Comparator.comparingInt(a -> a[0]));\n    int count = 1;\n\n    // right edge of current rectangle\n    int threshold = points[0][0] + w;\n    for (int[] point : points) {\n      // add new rectangle and increase threshold\n      if (point[0] > threshold) {\n        count++;\n        threshold = point[0] + w;\n      }\n    }\n\n    return count;\n  }\n}\n\n```
['Math', 'Greedy', 'Java']