C++ | Easy Understanding
intution :\nin each iteration you are traversing a square \n     ->  downwards -> leftwards ->upwards ->righwards\nwhile traversing check if the cell is within 
intution :\nin each iteration you are traversing a square \n     ->  downwards -> leftwards ->upwards ->righwards\nwhile traversing check if the cell is within the grid\nif with in the grid assign the value of count and increment count value\nafter each iteration update the value of l,r,t,b\n\nl = index of left most column\nr = index of right most column\nt = index of top  row\nb = index of bottom row\n```\nclass Solution {\npublic:\n    int m1,n1;\n    void solve(vector<vector<int>>&res,int r,int c,int &ct){\n        if(r>=0 && r<m1 && c>=0 && c<n1){\n            {res.push_back({r,c});ct++;}\n        }\n    }\n    vector<vector<int>> spiralMatrixIII(int m, int n, int rs, int cs) {\n        \n        vector<vector<int>>res;\n        res.push_back({rs,cs});\n        int l=cs-1,r=cs+1,t=rs-1,b=rs+1,ct=2;\n        m1=m;n1=n;\n        while(ct<=m*n){\n            for(int i=t+1;i<b;i++) solve(res,i,r,ct);\n            for(int i=r;i>=l;i--)  solve(res,b,i,ct);\n            for(int i=b-1;i>t;i--) solve(res,i,l,ct);\n            for(int i=l;i<=r;i++)  solve(res,t,i,ct);\n            r++;l--;t--;b++;\n        }\n        return res;\n    }\n};\n```\nplease upvote if you like .\nHappy coding :)
[]