Java Solution
Solution - \n\nclass Solution {\n    public int[][] spiralMatrixIII(int rows, int cols, int rStart, int cStart) {\n        int[][] ans = new int[rows*cols][2];\
Solution - \n```\nclass Solution {\n    public int[][] spiralMatrixIII(int rows, int cols, int rStart, int cStart) {\n        int[][] ans = new int[rows*cols][2];\n        int i=0;\n        ans[i++] = new int[]{rStart, cStart};\n        \n        int len=0;\n        int d=0;\n        int[] direction = new int[]{0, 1, 0, -1, 0};\n        \n        while(i < rows * cols){\n            if(d == 0 || d == 2){\n                len++;\n            }\n            for(int k=0; k<len; k++){\n                rStart += direction[d];\n                cStart += direction[d+1];\n                \n                if(rStart<rows && rStart>=0 && cStart<cols && cStart >= 0){\n                    ans[i++] = new int[]{rStart, cStart};\n                }\n            }\n            d = ++d % 4;\n        }\n        return ans;\n    }\n}\n```
['Array', 'Java']