We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5a2067f commit 198c9dfCopy full SHA for 198c9df
YoonYn9915/dp/2025-01-13-[백준]-#5582-공통 부분 문자열.py
@@ -0,0 +1,18 @@
1
+string1 = input()
2
+string2 = input()
3
+
4
+dp = [[0] * len(string1) for _ in range(len(string2))]
5
6
+for i in range(len(string2)):
7
+ for j in range(len(string1)):
8
+ # 두 문자열의 i번째 문자와 j번째 문자가 같을때
9
+ if string2[i] == string1[j]:
10
+ if i > 0 and j > 0:
11
+ dp[i][j] = dp[i-1][j-1] + 1
12
+ else:
13
+ dp[i][j] = 1
14
15
+ dp[i][j] = 0
16
17
+# dp테이블에서 최댓값 찾기
18
+print(max(max(row) for row in dp))
0 commit comments