Class Solution
java.lang.Object
g2301_2400.s2373_largest_local_values_in_a_matrix.Solution
2373 - Largest Local Values in a Matrix.<p>Easy</p>
<p>You are given an <code>n x n</code> integer matrix <code>grid</code>.</p>
<p>Generate an integer matrix <code>maxLocal</code> of size <code>(n - 2) x (n - 2)</code> such that:</p>
<ul>
<li><code>maxLocal[i][j]</code> is equal to the <strong>largest</strong> value of the <code>3 x 3</code> matrix in <code>grid</code> centered around row <code>i + 1</code> and column <code>j + 1</code>.</li>
</ul>
<p>In other words, we want to find the largest value in every contiguous <code>3 x 3</code> matrix in <code>grid</code>.</p>
<p>Return <em>the generated matrix</em>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2022/06/21/ex1.png" alt="" /></p>
<p><strong>Input:</strong> grid = [[9,9,8,1],[5,6,2,6],[8,2,6,4],[6,2,2,2]]</p>
<p><strong>Output:</strong> [[9,9],[8,6]]</p>
<p><strong>Explanation:</strong> The diagram above shows the original matrix and the generated matrix.</p>
<p>Notice that each value in the generated matrix corresponds to the largest value of a contiguous 3 x 3 matrix in grid.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2022/07/02/ex2new2.png" alt="" /></p>
<p><strong>Input:</strong> grid = [[1,1,1,1,1],[1,1,1,1,1],[1,1,2,1,1],[1,1,1,1,1],[1,1,1,1,1]]</p>
<p><strong>Output:</strong> [[2,2,2],[2,2,2],[2,2,2]]</p>
<p><strong>Explanation:</strong> Notice that the 2 is contained within every contiguous 3 x 3 matrix in grid.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == grid.length == grid[i].length</code></li>
<li><code>3 <= n <= 100</code></li>
<li><code>1 <= grid[i][j] <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
largestLocal
public int[][] largestLocal(int[][] grid)
-