✅💯🔥Simple Code🚀📌|| 🔥✔️Easy to understand🎯 || 🎓🧠Beats 100%🔥|| Beginner friendly💀💯
Tuntun Mosi ko Pranam\nSolution tuntun mosi ki photo ke baad hai. Scroll Down\n\n# Code\njava []\nclass Solution {\n    public int[][] spiralMatrixIII(int row, 
# Tuntun Mosi ko Pranam\nSolution tuntun mosi ki photo ke baad hai. Scroll Down\n![fd9d3417-20fb-4e19-98fa-3dd39eeedf43_1723794694.932518.png](https://assets.leetcode.com/users/images/a492c0ef-bde0-4447-81e6-2ded326cd877_1724187540.6168394.png)\n# Code\n```java []\nclass Solution {\n    public int[][] spiralMatrixIII(int row, int col, int r, int c) {\n        int a = 0;\n        int[][] ans = new int[row * col][2];\n        boolean[][] visited = new boolean[row][col];\n        int top = r, bottom = r + 1, left = c, right = c + 1;\n        while (a < row * col) {\n            for (int i = left; i <= right; i++) {\n                if (i >= 0 && i < col && top >= 0 && top < row && !visited[top][i]) {\n                    ans[a][0] = top;\n                    ans[a][1] = i;\n                    visited[top][i] = true;\n                    a++;\n                }\n            }\n            for (int i = top + 1; i <= bottom; i++) {\n                if (i >= 0 && i < row && right >= 0 && right < col && !visited[i][right]) {\n                    ans[a][0] = i;\n                    ans[a][1] = right;\n                    visited[i][right] = true;\n                    a++;\n                }\n            }\n            left--;\n            top--;\n            for (int i = right - 1; i >= left; i--) {\n                if (i >= 0 && i < col && bottom >= 0 && bottom < row && !visited[bottom][i]) {\n                    ans[a][0] = bottom;\n                    ans[a][1] = i;\n                    visited[bottom][i] = true;\n                    a++;\n                }\n            }\n            for (int i = bottom - 1; i >= top; i--) {\n                if (i >= 0 && i < row && left >= 0 && left < col && !visited[i][left]) {\n                    ans[a][0] = i;\n                    ans[a][1] = left;\n                    visited[i][left] = true;\n                    a++;\n                }\n            }\n            bottom++;\n            right++;\n        }\n        return ans;\n    }\n}\n\n```\n![7be995b4-0cf4-4fa3-b48b-8086738ea4ba_1699897744.9062278.jpeg](https://assets.leetcode.com/users/images/fe5117c9-43b1-4ec8-8979-20c4c7f78d98_1721303757.4674635.jpeg)
['Array', 'C', 'Matrix', 'Simulation', 'Python', 'C++', 'Java', 'JavaScript']