私のコードは LCS の長さを計算するために機能しますが、次のリンクで LCS を読み取るために同じコードを適用します。
http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
しかし、一部の文字列が欠落しています。私が欠けているものを教えていただけますか?
Google Playground リンク: http://play.golang.org/p/qnIWQqzAf5
func Back(table [][]int, str1, str2 string, i, j int) string {
if i == 0 || j == 0 {
return ""
} else if str1[i] == str2[j] {
return Back(table, str1, str2, i-1, j-1) + string(str1[i])
} else {
if table[i][j-1] > table[i-1][j] {
return Back(table, str1, str2, i, j-1)
} else {
return Back(table, str1, str2, i-1, j)
}
}
}
前もって感謝します。