# Maximum Non Negative Product in a Matrix SOLUTION

Page Contents

### Maximum Non Negative Product in a Matrix SOLUTION

You are given a lines x cols framework network. At first, you are situated at the upper left corner (0, 0), and in each progression, you can just move right or down in the network.

Among all potential ways beginning from the upper left corner (0, 0) and finishing off with the base right corner (lines – 1, cols – 1), discover the way with the greatest non-negative item. The result of a way is the result of all whole numbers in the matrix cells visited along the way.

Return the greatest non-negative item modulo 109 + 7. In the event that the greatest item is negative return – 1.

Notice that the modulo is performed subsequent to getting the greatest item.

Model 1:

Info: framework = [[-1,- 2,- 3],

[-2,- 3,- 3],

[-3,- 3,- 2]]

Yield: – 1

Clarification: It’s unrealistic to get non-negative item in the way from (0, 0) to (2, 2), so return – 1.

Model 2:

Info: framework = [[1,- 2,1],

[1,- 2,1],

[3,- 4,1]]

Yield: 8

Clarification: Maximum non-negative item is in intense (1 * 1 * – 2 * – 4 * 1 = 8).

Model 3:

Info: framework = [[1, 3],

[0,- 4]]

Yield: 0

Clarification: Maximum non-negative item is in intense (1 * 0 * – 4 = 0).

Model 4:

Info: lattice = [[ 1, 4,4,0],

[-2, 0,0,1],

[ 1,- 1,1,1]]

Yield: 2

Clarification: Maximum non-negative item is in intense (1 * – 2 * 1 * – 1 * 1 * 1 = 2).

Imperatives:

1 <= columns, cols <= 15

– 4 <= grid[i][j] <= 4