100% || C++
Intuition
Here you have to increase your step count if you switch to east or west direction, otherwise keep going ahead
Go from [0,step] for every direction
Cod
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

- Here you have to increase your step count if you switch to east or west direction, otherwise keep going ahead
- Go from `[0,step]` for every direction


# Code
```cpp []
class Solution {
public:
    vector<vector<int>> spiralMatrixIII(int rows, int cols, int rStart, int cStart) {
        vector<vector<int>> directions={
            {0, 1}, //E
            {1, 0}, //S
            {0, -1}, //W
            {-1, 0} //N
        };
        vector<vector<int>> ans;
        ans.push_back({rStart,cStart});

        int step=0;
        int dir=0;

        while(ans.size()<rows*cols){
            if(dir==0 || dir==2) step++; // east or west
            for(int i=0;i<step;i++){
                rStart+=directions[dir][0];
                cStart+=directions[dir][1];
                
                if(rStart>=0 && rStart<rows && cStart>=0 && cStart<cols){
                    ans.push_back({rStart,cStart});
                }
            }
            dir=(dir+1)%4;
        }
        return ans;
    }
};
```
['C++']