C++ || Easy Video Solution
The video solution to the below code is\nhttps://youtu.be/rRb2S-_vQRw\n\n# Code\n\nclass Solution {\npublic:\n    vector<vector<int>> spiralMatrixIII(int rows, 
The video solution to the below code is\nhttps://youtu.be/rRb2S-_vQRw\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> spiralMatrixIII(int rows, int cols, int rStart, int cStart) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(NULL);\n        cout.tie(NULL);\n        // Move 1 step in East directon\n        // Move 1 step in South direction\n        // Move 2 steps in West direction\n        // Move 2 steps in North direction\n        // Move 3 steps in Eash direction\n        // Move 3 steps in South direction\n        // ......\n        // We are moving as a pairs of directions with equal step size. In other way East and South at the current iteration would be having same step size and then in the next iteration the step size would be increased by one and then west and north will be having same step size that got incremented by one.\n        // dr --> (dx, dy)\n        vector<vector<int>> dr = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};\n        int stepSize = 1;\n        vector<vector<int>> traversed;\n        int dir = 0;\n        while(traversed.size() < rows * cols){\n            for(int i = 0 ; i <= 1 ; i++){\n                for(int j = 0 ; j < stepSize ; j++){\n                    if(rStart >= 0 and rStart < rows and cStart >= 0 and cStart < cols){\n                        traversed.push_back({rStart, cStart});\n                    }\n                    rStart += dr[dir][0];\n                    cStart += dr[dir][1];\n                }\n                dir = (dir + 1) % 4;\n            }\n            stepSize++;\n        }\n        return traversed;\n    }\n};\n```
['C++']