Microsoft⭐ || Easy Solution🔥
#ReviseWithArsh #6Companies30Days challenge 2k24\nCompany 2 :- Microsoft\n\n\n# Code\n\nclass Solution {\npublic:\n    Solution(std::vector<std::vector<int>>& r
***#ReviseWithArsh #6Companies30Days challenge 2k24\nCompany 2 :- Microsoft***\n\n\n# Code\n```\nclass Solution {\npublic:\n    Solution(std::vector<std::vector<int>>& rects)\n        : rects(rects), x(rects[0][0] - 1), y(rects[0][1]), i(0) {}\n\n    std::vector<int> pick() {\n        // Increment x until reaching the right boundary of the current rectangle\n        if (x != rects[i][2]) {\n            ++x;\n        }\n        // If x reaches the right boundary, reset x to the left boundary and increment y\n        else if (x == rects[i][2] && y != rects[i][3]) {\n            x = rects[i][0];\n            ++y;\n        }\n        // If both x and y reach the boundaries, move to the next rectangle\n        else if (x == rects[i][2] && y == rects[i][3]) {\n            i = (i < rects.size() - 1) ? i + 1 : 0;\n            x = rects[i][0];\n            y = rects[i][1];\n        }\n        return {x, y};\n    }\n\nprivate:\n    std::vector<std::vector<int>> rects;\n    int x, y, i; // x, y represent the current point, i represents the current rectangle index\n};\n\n```
['C++']