From 61cac9c0febbb5440b99e22770d917bf3a63c405 Mon Sep 17 00:00:00 2001 From: MZuenni Date: Wed, 11 Jan 2023 11:15:50 +0100 Subject: dont use .size() --- string/longestCommonSubsequence.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'string/longestCommonSubsequence.cpp') 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> m(a.size() + 1, vector(b.size() + 1)); - for(int y = a.size() - 1; y >= 0; y--) { - for(int x = b.size() - 1; x >= 0; x--) { + vector> m(sz(a) + 1, vector(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++; -- cgit v1.2.3