From 27758d2b3bd252116b8d957443c27720d23d95b3 Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Mon, 24 Nov 2025 23:54:45 +0900 Subject: [PATCH] =?UTF-8?q?[20251123]=20BOJ=20/=20G5=20/=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=20=EB=B6=80=EB=B6=84=20=EB=AC=B8=EC=9E=90=20/=20?= =?UTF-8?q?=EC=84=A4=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement solution for finding the longest common substring. --- ...70\354\236\220\354\227\264\342\200\216.md" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "Seol-JY/202511/24 BOJ G5 \352\263\265\355\206\265 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\342\200\216.md" diff --git "a/Seol-JY/202511/24 BOJ G5 \352\263\265\355\206\265 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\342\200\216.md" "b/Seol-JY/202511/24 BOJ G5 \352\263\265\355\206\265 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\342\200\216.md" new file mode 100644 index 00000000..eb233cb4 --- /dev/null +++ "b/Seol-JY/202511/24 BOJ G5 \352\263\265\355\206\265 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264\342\200\216.md" @@ -0,0 +1,29 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + String s1 = br.readLine(); + String s2 = br.readLine(); + + int n = s1.length(); + int m = s2.length(); + int[][] dp = new int[n + 1][m + 1]; + int maxLen = 0; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= m; j++) { + if (s1.charAt(i - 1) == s2.charAt(j - 1)) { + dp[i][j] = dp[i - 1][j - 1] + 1; + maxLen = Math.max(maxLen, dp[i][j]); + } + } + } + + System.out.println(maxLen); + } +} +```