getLongest
func main () { fmt . Print ( getLongest ( "111131111" )) } func getLongest ( input string ) string { arr := make ([][] bool , len ( input )) for i := range arr { arr [ i ] = make ([] bool , len ( input )) } r := input [ 0 : 1 ] for i := 0 ; i < len ( input ); i ++ { arr [ i ][ i ] = true if i != len ( input )- 1 && input [ i ] == input [ i + 1 ] { r = input [ i : i + 1 ] arr [ i ][ i + 1 ] = true } } for lenght := 3 ; lenght <= len ( input ); lenght ++ { for i := 0 ; i < len ( input ); i ++ { j := i + lenght - 1 if j < len ( input ) && isPar ( i , j , input , arr ) { arr [ i ][ j ] = true r = input [ i : j + 1 ] } } } return r } func isPar ( i , j int , s string , arr [][] bool ) bool { if i == j { arr [ i ][ j ] = true return true } else { if i + 1 == j && s [ i ] == s [ j ]...