We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 32fef6c commit 951bc09Copy full SHA for 951bc09
Solutions/[13]_1.java
@@ -0,0 +1,26 @@
1
+import java.util.Scanner;
2
+
3
+public class Main {
4
5
+ public static void main(String[] args) {
6
+ Scanner sc = new Scanner(System.in);
7
8
+ String x = sc.nextLine();
9
+ String y = sc.nextLine();
10
+ int[][] dp = new int[1001][1001];
11
12
+ for (int i = 1; i <= x.length(); i++) {
13
+ for (int j = 1; j <= y.length(); j++) {
14
+ if (x.charAt(i - 1) == y.charAt(j - 1)) {
15
+ dp[i][j] = dp[i - 1][j - 1] + 1;
16
+ }
17
+ else {
18
+ dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
19
20
21
22
23
+ System.out.println(dp[x.length()][y.length()]);
24
25
26
+}
0 commit comments