Tap here to switch tabs
Problem
Submissions

Problem: Maximum Non Negative Product in a Matrix

med
30 min
Try to solve the Maximum Non Negative Product in a Matrix problem.

Statement

You are given an m $ imes$ n matrix grid. You start at cell (0,0)(0, 0) and want to reach cell (m−1,n−1)(m - 1, n - 1) by moving only right or down at any step.

The product of a path is the result of multiplying the values of all cells traversed along the path.

Return the maximum non negative product of a path from (0,0)(0, 0) to (m−1,n−1)(m - 1, n - 1) modulo 109+710^9 + 7. If the maximum product is negative, return −1-1.

Note: The modulo operation is applied after determining the maximum product.

Constraints:

  • m ==== grid.length

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

  • 1≤1 \leq m, n ≤15\leq 15

  • −4≤-4 \leq grid[i][j] ≤4\leq 4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Non Negative Product in a Matrix

med
30 min
Try to solve the Maximum Non Negative Product in a Matrix problem.

Statement

You are given an m $ imes$ n matrix grid. You start at cell (0,0)(0, 0) and want to reach cell (m−1,n−1)(m - 1, n - 1) by moving only right or down at any step.

The product of a path is the result of multiplying the values of all cells traversed along the path.

Return the maximum non negative product of a path from (0,0)(0, 0) to (m−1,n−1)(m - 1, n - 1) modulo 109+710^9 + 7. If the maximum product is negative, return −1-1.

Note: The modulo operation is applied after determining the maximum product.

Constraints:

  • m ==== grid.length

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

  • 1≤1 \leq m, n ≤15\leq 15

  • −4≤-4 \leq grid[i][j] ≤4\leq 4