🔥Simple || Easy || Beats 100% 100%
Complexity\n- Time complexity:\nO(n.log(n)) \n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    int minRectanglesToCoverPoints(vector<vect
# Complexity\n- Time complexity:\n$$O(n.log(n))$$ \n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int minRectanglesToCoverPoints(vector<vector<int>>& points, int w) {\n        \n        ios_base::sync_with_stdio(false);\n        cin.tie(nullptr);\n        cout.tie(nullptr);\n        \n        int n = points.size();\n        int cnt = 0;\n        int p = 0;\n        int i = 0;\n        \n        sort(points.begin(), points.end());\n        \n        while(i < n){\n            p = points[i][0] + w;\n            while(i < n && points[i][0] <= p){\n                i++;\n            }\n            cnt++;\n        }\n        return cnt;\n    }\n};\n```
['Two Pointers', 'Sorting', 'C++']