# 2373. Largest Local Values in a Matrix ###### tags: `Leetcode` `Easy` Link: https://leetcode.com/problems/largest-local-values-in-a-matrix/description/ ## Code ```java= class Solution { public int[][] largestLocal(int[][] grid) { int n = grid.length; int[][] ans = new int[n-2][n-2]; for(int i=1; i<n-1; i++){ for(int j=1; j<n-1; j++){ ans[i-1][j-1] = grid[i][j]; for(int x=i-1; x<=i+1; x++){ for(int y=j-1; y<=j+1; y++){ ans[i-1][j-1] = Math.max(ans[i-1][j-1], grid[x][y]); } } } } return ans; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up