From 2e5264a73073299b2a697df1838c3860d0f7775e Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Sun, 23 Nov 2025 23:54:28 +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=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\204 \353\254\270\354\236\220\354\227\264" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "LiiNi-coder/202511/23 BOJ \352\263\265\355\206\265 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264" diff --git "a/LiiNi-coder/202511/23 BOJ \352\263\265\355\206\265 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264" "b/LiiNi-coder/202511/23 BOJ \352\263\265\355\206\265 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264" new file mode 100644 index 00000000..c8d035f3 --- /dev/null +++ "b/LiiNi-coder/202511/23 BOJ \352\263\265\355\206\265 \353\266\200\353\266\204 \353\254\270\354\236\220\354\227\264" @@ -0,0 +1,32 @@ +```java +import java.io.*; +import java.util.*; + +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 len1 = s1.length(); + int len2 = s2.length(); + + + int[][] dp = new int[len1 + 1][len2 + 1]; + int maxLen = 0; + for(int i = 1; i <= len1; i++){ + for(int j = 1; j <= len2; j++){ + if(s1.charAt(i - 1) == s2.charAt(j - 1)){ + dp[i][j] = dp[i - 1][j - 1] + 1; + if(dp[i][j] > maxLen){ + maxLen = dp[i][j]; + } + } else { + dp[i][j] = 0; + } + } + } + System.out.println(maxLen); + } +} + +```