Sort and Increment count on the basis of x-values | Easy |
\n\n# Code\n\nclass Solution {\npublic:\n    int minRectanglesToCoverPoints(vector<vector<int>>& p, int w) {\n        sort(p.begin() , p.end());\n        int n 
\n\n# Code\n```\nclass Solution {\npublic:\n    int minRectanglesToCoverPoints(vector<vector<int>>& p, int w) {\n        sort(p.begin() , p.end());\n        int n = p.size();\n        int cnt = 0;\n        \n        int valid = -1;\n        \n        for(int i = 0 ; i < n ; i++)\n        {\n            int x1 = p[i][0];\n            int y = p[i][1];\n            \n            if(x1 <= valid)\n            {\n                continue;\n            }\n            else\n            {\n                cnt++;\n                int x2 = x1 + w;\n                valid = x2;\n            }\n        }\n        \n        return cnt;\n    }\n};\n```
['Sorting', 'C++']