look left
if ( j > 0 && Math . abs ( mat [ i ] [ j - 1 ] - mat [ i ] [ j ] ) == 1 ) { lookup [ i ] [ j ] = Math . max ( lookup [ i ] [ j ] , lookup [ i ] [ j - 1 ] + 1 ) ; if ( max_len < lookup [ i ] [ j ] ) { max_len = lookup [ i ] [ j ] ; max_row = i ; max_col = j ; } } } } } System . out . print ( " Maximum ▁ length ▁ of ▁ Snake ▁ " + " sequence ▁ is : ▁ " + max_len + "NEW_LINE");