funcmain() { for { var m, n string if _, err := fmt.Scan(&m); err != nil { return } if _, err := fmt.Scan(&n); err != nil { return } m = strings.ToLower(m) n = strings.ToLower(n) var max int var dp [][]int = make([][]int, len(m)+1) for i := range dp { dp[i] = make([]int, len(n)+1) } for i := 1; i <= len(m); i++ { for j := 1; j <= len(n); j++ { if m[i-1] == n[j-1] { dp[i][j] = dp[i-1][j-1] + 1 } if dp[i][j] > max { max = dp[i][j] } }
var maxLen int for i := 0; i < len(shortStr); i++ { for j := 1; j <= len(shortStr) - i; j++ { if strings.Contains(longStr, shortStr[i:i+j]) { if maxLen < j { maxLen = j } } }