Tap here to switch tabs
Problem
Submissions

Problem: Largest Local Values in a Matrix

med
30 min
Try to solve the Largest Local Values in a Matrix problem.

Statement

You are given an n ×\times n integer matrix grid.

Construct an (n −2- 2) ×\times (n −2- 2) integer matrix maxLocal such that maxLocal[i][j] is equal to the maximum value in the 3×33 \times 3 submatrix of grid centered around row i +1+ 1 and column j +1+ 1.

Return the matrix maxLocal.

Constraints:

  • n ==== grid.length ==== grid[i].length

  • 3≤3 \leq n ≤100\leq 100

  • 1≤1 \leq grid[i][j] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Largest Local Values in a Matrix

med
30 min
Try to solve the Largest Local Values in a Matrix problem.

Statement

You are given an n ×\times n integer matrix grid.

Construct an (n −2- 2) ×\times (n −2- 2) integer matrix maxLocal such that maxLocal[i][j] is equal to the maximum value in the 3×33 \times 3 submatrix of grid centered around row i +1+ 1 and column j +1+ 1.

Return the matrix maxLocal.

Constraints:

  • n ==== grid.length ==== grid[i].length

  • 3≤3 \leq n ≤100\leq 100

  • 1≤1 \leq grid[i][j] ≤100\leq 100