アルゴリズムの質問が 1 つあります。
質問は次のとおりです。
文字 A、B、C、D で構成されるタンパク質文字列が与えられます。その中で最小長のシーケンスを見つける必要があります。
例
0 1 2 3 4 5 6 7 8 9 10 11 12
A B A C D C A B C D C C D
String to find is : BCD
This string is find between (StartPoint, EndPoint)
1, 4
7, 9
1, 12
7, 12
Minimum length is of 7, 9.
So the answer is 7, 9
私の仕事、
- O(n ^ 2)でブルートフォースアプローチを使用してこれを解決できます。
- DP を使用して、メイン ストリングに存在する最初のシーケンスを見つけることができます。私の DP ロジックは次のとおりです。
A = Main string B = String to be find DP = Dynamic programming function n = A.size, m = B.size Build an array of DP[m+1][n+1] DP[i][j], means If in A[0...i], B[0...j] is present or not. This way we can find our first occurence of B in A. Now after this, I am stuck.
あなたの側からのヒントが必要です。
ヒント/ガイダンスのみを提供してください。コードや実装は必要ありません。