Growing phase
if ( s != 1 ) { dp [ i ] [ j ] [ s ] = arr [ i ] [ j ] + Math . max ( maxScore ( arr , i + 1 , j , s ) , Math . max ( maxScore ( arr , i , j + 1 , s ) , maxScore ( arr , i - 1 , j , ( s == 1 ) ? 0 : 1 ) ) ) ;