Beats 100% users both time and space complexity || Java solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn) --> sorting dominant\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```\nclass Solution {\n    public int minRectanglesToCoverPoints(int[][] arr, int w) {\n        int n = arr.length, res = 0, i=0;\n        Arrays.sort(arr, (a,b) -> Integer.compare(a[0],b[0]));\n        while(i<n){\n            // System.out.println(i);\n            int first = arr[i][0];\n            int j=i+1;\n            while(j<n){\n                if(arr[j][0]-first <= w) {\n                    j++;\n                }\n                else break;\n            }\n            res++;\n            i = j;\n        }\n        return res;\n    }\n}\n```
['Sorting', 'Java']