diff options
| author | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-10 21:40:43 +0200 |
|---|---|---|
| committer | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-10 21:40:43 +0200 |
| commit | f1d5de7e374c215ce3da513d1dc3bb2577c1dc3e (patch) | |
| tree | 6d0d195884ba804e9b777a4610f6004e53a1de60 /string/LCSubSequence.cpp | |
| parent | c245ad9089aeb8c7fc7683b6a8a20d04a74818f4 (diff) | |
Typesetting string section.
Diffstat (limited to 'string/LCSubSequence.cpp')
| -rw-r--r-- | string/LCSubSequence.cpp | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/string/LCSubSequence.cpp b/string/LCSubSequence.cpp deleted file mode 100644 index 0ea2913..0000000 --- a/string/LCSubSequence.cpp +++ /dev/null @@ -1,17 +0,0 @@ -string lcss(string &a, string &b) { - int m[a.length() + 1][b.length() + 1], x=0, y=0; - memset(m, 0, sizeof(m)); - for(int y = a.length() - 1; y >= 0; y--) { - for(int x = b.length() - 1; x >= 0; x--) { - if(a[y] == b[x]) m[y][x] = 1 + m[y+1][x+1]; - else m[y][x] = max(m[y+1][x], m[y][x+1]); - } - } //for length only: return m[0][0]; - string res; - while(x < b.length() && y < a.length()) { - if(a[y] == b[x]) res += a[y++], x++; - else if(m[y][x+1] > m[y+1][x+1]) x++; - else y++; - } - return res; -} |
