End of Year Sale: Use Coupon Code END2025 to Get Extra 25% Off.
maxProduct and minProduct of the same size as the input grid, to store the maximum and minimum product paths respectively.maxProduct and minProduct to the value of the first cell in the grid.maxProduct and minProduct matrices with the maximum and minimum of these values, respectively.maxProduct.-1. Otherwise, return the value modulo 10^9 + 7.