If we 're not at the  above, we can consider  the above value.
if ( i > 0 ) { int tempMax = Math . Max ( maxPath [ i - 1 , j ] * arr [ i , j ] , minPath [ i - 1 , j ] * arr [ i , j ] ) ; maxVal = Math . Max ( maxVal , tempMax ) ; int tempMin = Math . Min ( maxPath [ i - 1 , j ] * arr [ i , j ] , minPath [ i - 1 , j ] * arr [ i , j ] ) ; minVal = Math . Min ( minVal , tempMin ) ; }