Easy To Understand Approach || Commented
Code\n\nclass Solution {\npublic:\n    bool isValid(int nrow,int ncol,int n,int m){\n        return nrow>=0 && nrow<n && ncol>=0 && ncol<m ;\n    }\n    vector<
# Code\n```\nclass Solution {\npublic:\n    bool isValid(int nrow,int ncol,int n,int m){\n        return nrow>=0 && nrow<n && ncol>=0 && ncol<m ;\n    }\n    vector<vector<int>> spiralMatrixIII(int rows, int cols, int rStart, int cStart) {\n        vector<vector<int>>spiral;\n        spiral.push_back({rStart,cStart});\n        //till now, 1 coordinate used \n        int used=1,move=1; \n        while(used<rows*cols){\n \n            //for right movement first [1,2,3...]\n            int canMove=move;\n            while(canMove--){\n                //row remains same column changes\n                cStart++;\n                //if new position valid take it in spiral order \n                if(isValid(rStart,cStart,rows,cols)){\n                     spiral.push_back({rStart,cStart});\n                     used++; //another coordinate used \n                }\n            }\n\n            //for down movement \n              canMove=move;\n            while(canMove--){\n                //column remains same row changes\n                rStart++;\n                //if new position valid take it in spiral order \n                if(isValid(rStart,cStart,rows,cols)){\n                     spiral.push_back({rStart,cStart});\n                     used++; //another coordinate used \n                }\n            }\n            //AFTER ONE SET OF RIGHT-DOWN MOVEMENT MOVE INCREASES BY 1 \n            move++;\n            \n\n            //for left movement \n              canMove=move;\n            while(canMove--){\n                //row remains same column changes\n                cStart--;\n                //if new position valid take it in spiral order \n                if(isValid(rStart,cStart,rows,cols)){\n                     spiral.push_back({rStart,cStart});\n                     used++; //another coordinate used \n                }\n            }\n            \n            //for up movement \n              canMove=move;\n            while(canMove--){\n                //column remains same row changes\n                rStart--;\n                //if new position valid take it in spiral order \n                if(isValid(rStart,cStart,rows,cols)){\n                     spiral.push_back({rStart,cStart});\n                     used++; //another coordinate used \n                }\n            }\n            //AFTER ONE SET OF LEFT-UP MOVEMENT MOVE INCREASES BY 1 \n            move++;\n        }\n        return spiral;\n    }\n};\n```\n```\nIf you find this solutions to be helpful do upvote..It keeps me motivated :)\n```
['C++']