C++ || Easy Explanation & Solution
\nclass Solution {\npublic:\n    vector<vector<int>> spiralMatrixIII(int rows, int cols, int rStart, int cStart) {\n        \n        vector<vector<int>> ans;\n
```\nclass Solution {\npublic:\n    vector<vector<int>> spiralMatrixIII(int rows, int cols, int rStart, int cStart) {\n        \n        vector<vector<int>> ans;\n        ans.push_back({rStart, cStart}); //Pushing the starting point in answer\n        int topRow = rStart-1; //Row above starting point\n        int bottomRow = rStart+1; //Row below starting point\n        int leftCol = cStart-1; //Col left to starting point\n        int rightCol = cStart+1; //Col right to starting point\n        \n        while(topRow != -1 || bottomRow != rows || leftCol != -1 || rightCol != cols){ //Untill all rows and columns are exhausted\n            \n            if(rightCol != cols){ //Checking if this col is exhausted\n                for(int i = topRow+1; i < bottomRow;i++) ans.push_back({i, rightCol}); //Running loop from one bottom of top row till bottom row in right col\n                rightCol++; //Incrementing the col forward\n            }\n            //Similar things are done below with different cols and rows\n            if(bottomRow != rows){\n                for(int j = rightCol-1; j > leftCol; j--) ans.push_back({bottomRow, j});\n                bottomRow++;\n            }\n            \n            if(leftCol != -1){\n                for(int i = bottomRow-1; i > topRow; i--) ans.push_back({i, leftCol});\n                leftCol--;\n            }\n            \n            if(topRow != -1){\n                for(int j = leftCol+1; j < rightCol; j++) ans.push_back({topRow, j});\n                topRow--;\n            }  \n        }\n        return ans;\n    }\n};\n```\n\nIf you think this post was ***helpful***, I will be happy if you give a ***upvote***. Any questions or discussions are welcome! **Thanks a lot.** \uD83D\uDE04
['C', 'C++']