Skip to content

Commit 5f0a2b0

Browse files
authored
Create [13]_1.cpp
1 parent 951bc09 commit 5f0a2b0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Solutions/[13]_1.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
string x, y;
6+
int dp[1001][1001];
7+
8+
int main() {
9+
cin >> x >> y;
10+
11+
for (int i = 1; i <= x.length(); i++) {
12+
for (int j = 1; j <= y.length(); j++) {
13+
if (x[i - 1] == y[j - 1]) {
14+
dp[i][j] = dp[i - 1][j - 1] + 1;
15+
}
16+
else {
17+
dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
18+
}
19+
}
20+
}
21+
22+
cout << dp[x.length()][y.length()];
23+
}

0 commit comments

Comments
 (0)