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