summaryrefslogtreecommitdiff
path: root/string/longestCommonSubsequence.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'string/longestCommonSubsequence.cpp')
-rw-r--r--string/longestCommonSubsequence.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/string/longestCommonSubsequence.cpp b/string/longestCommonSubsequence.cpp
index dd2368e..fa1adb6 100644
--- a/string/longestCommonSubsequence.cpp
+++ b/string/longestCommonSubsequence.cpp
@@ -1,12 +1,12 @@
string lcss(string& a, string& b) {
- vector<vector<int>> m(a.size() + 1, vector<int>(b.size() + 1));
- for(int y = a.size() - 1; y >= 0; y--) {
- for(int x = b.size() - 1; x >= 0; x--) {
+ vector<vector<int>> m(sz(a) + 1, vector<int>(sz(b) + 1));
+ for(int y = sz(a) - 1; y >= 0; y--) {
+ for(int x = sz(b) - 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]);
}} // Für die Länge: return m[0][0];
string res; int x=0; int y=0;
- while(x < b.size() && y < a.size()) {
+ while(x < sz(b) && y < sz(a)) {
if(a[y] == b[x]) res += a[y++], x++;
else if(m[y][x+1] > m[y+1][x+1]) x++;
else y++;