Tap here to switch tabs
Problem
Submissions

Problem: Modify the Matrix

med
30 min
Try to solve the Modify the Matrix problem.

Statement

Given a 00 indexed m×nm \times n integer matrix matrix, construct a 00 indexed matrix answer of the same dimensions. Initially, let answer be identical to matrix. For every cell (i, j) where matrix[i][j] is equal to −1-1, replace answer[i][j] with the maximum value found in column j.

Return the matrix answer.

Constraints:

  • m == matrix.length

  • n == matrix[i].length

  • 2≤2 \leq m, n ≤50\leq 50

  • −1≤-1 \leq matrix[i][j] ≤100\leq 100

  • The input is generated such that each column contains at least one nonnegative integer.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Modify the Matrix

med
30 min
Try to solve the Modify the Matrix problem.

Statement

Given a 00 indexed m×nm \times n integer matrix matrix, construct a 00 indexed matrix answer of the same dimensions. Initially, let answer be identical to matrix. For every cell (i, j) where matrix[i][j] is equal to −1-1, replace answer[i][j] with the maximum value found in column j.

Return the matrix answer.

Constraints:

  • m == matrix.length

  • n == matrix[i].length

  • 2≤2 \leq m, n ≤50\leq 50

  • −1≤-1 \leq matrix[i][j] ≤100\leq 100

  • The input is generated such that each column contains at least one nonnegative integer.