🔥💯Beats 100% of users with Java🎉||✅ one line loop code ||  2 Sec to understand 🎉🎊
Sreenshot\n\n\n\n---\n\n\n# Intuition\n\n> Follow the steps and you will also solve this in 2 Sec.\n Describe your first thoughts on how to solve this problem. 
# Sreenshot\n![2373.png](https://assets.leetcode.com/users/images/986d411f-86d9-4760-97c3-6560680439a1_1715494395.2482102.png)\n\n\n---\n\n\n# Intuition\n\n> Follow the steps and you will also solve this in 2 Sec.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n- We need to return a `(n - 2) x (n - 2) `grid combination.\n- In which each element `[i][j]` will be the `max` value of a maxtrix.\n- Matrix that is made by `9` Elements which are present in main `Grid`\n- Matrix will be contain `3 col and 3 row`.\n- `row and col` we\'ll get by the `element\'s position`.\n- `Row` will be `i to i + 3`.\n- `Col` will be `j to j + 3`.\n\n---\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Take the value of `(grid.lenght - 2 )` in a veriable .\n\n2. And make a Array of `(n - 2) x (n - 2) ` \n    ```\n     int n = grid.length - 2;\n\n        // Making a submit Array of (n - 2) x (n - 2)\n        int[][] subArr = new int[n][n];\n    ```\n3. **Now we\'ll write our one line code in 2 for loop :**\n\n    - We\'ll take our max value from a function and store too our array\n\n    - We\'ll run 2 for loop\n\n    ```\n     for (int i = 0; i < n; i++) {\n            for (int j = 0; j < n; j++) {\n            // We\'ll take max value from our another function...\n                subArr[i][j] = giveMaxValue(grid, i, j);\n            }\n        }\n    ```\n\n4. Make a `function` with `3 Args` That will `Grid Row Col`.\n\n5. And we\'ll `return MaxValue` of this `given Matrix`.\n\n    - Take a `MaxValue variable` assign with 0 \n    - `Apply 2 for loops` and `Find the max value` of given matrix.\n\n    ```\n        int maxValue = 0;\n\n        for (int i = row; i < row + 3; i++) {\n            for (int j = col; j < col + 3; j++) {\n                maxValue = Math.max(maxValue, grid[i][j]);\n            }\n        }\n\n    ```\n    - Finally return the maxValue.\n\n6. `return our Array`.\n\n---\n\n\n# Complexity\n- Time complexity: $$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n^2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n---\n\n\n# Code\n```\nclass Solution {\n\n    public int giveMaxValue(int[][] grid, int row, int col) {\n        int maxValue = 0;\n\n        for (int i = row; i < row + 3; i++) {\n            for (int j = col; j < col + 3; j++) {\n                // max value to our maxValue variable...\n                maxValue = Math.max(maxValue, grid[i][j]);\n            }\n        }\n\n        return maxValue;\n    }\n\n    public int[][] largestLocal(int[][] grid) {\n        int n = grid.length - 2;\n\n        // Making a submit Array of (n - 2) x (n - 2)\n        int[][] subArr = new int[n][n];\n\n        for (int i = 0; i < n; i++) {\n            for (int j = 0; j < n; j++) {\n            // Every element of submit array will give by this fun\n                subArr[i][j] = giveMaxValue(grid, i, j);\n            }\n        }\n\n        return subArr;\n    }\n}\n```\n![upvote-this-you.jpg](https://assets.leetcode.com/users/images/20d48492-5376-43c9-84ae-71a6371f5317_1715496251.8272567.jpeg)\n\n
['Array', 'Matrix', 'Java']