From 2e05f78631a818ccb9db80d117dbd33eade211b0 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Mon, 3 Feb 2025 15:38:36 +0900 Subject: [PATCH] =?UTF-8?q?=20[20250203]=20BOJ=20/=20=EA=B3=A8=EB=93=9C3?= =?UTF-8?q?=20/=20=ED=8C=B0=EB=A6=B0=EB=93=9C=EB=A1=AC=20/=20=EA=B9=80?= =?UTF-8?q?=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...60\353\246\260\353\223\234\353\241\254.md" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "suyeun84/202502/03 BOJ G3 \355\214\260\353\246\260\353\223\234\353\241\254.md" diff --git "a/suyeun84/202502/03 BOJ G3 \355\214\260\353\246\260\353\223\234\353\241\254.md" "b/suyeun84/202502/03 BOJ G3 \355\214\260\353\246\260\353\223\234\353\241\254.md" new file mode 100644 index 00000000..c55cb8f8 --- /dev/null +++ "b/suyeun84/202502/03 BOJ G3 \355\214\260\353\246\260\353\223\234\353\241\254.md" @@ -0,0 +1,35 @@ +```java +import java.util.*; +import java.io.*; + +class Solution +{ + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st = new StringTokenizer(br.readLine()); + + int N = Integer.parseInt(st.nextToken()); + String target = br.readLine().trim(); + String reverseTarget = ""; + StringBuilder sb = new StringBuilder(); + int[][] dp = new int[N+1][N+1]; + for (int i = N-1; i > -1; i--) { + sb.append(target.charAt(i)); + } + reverseTarget = sb.toString(); + + for (int i = 1; i < N+1; i++) { + for (int j = 1; j < N+1; j++) { + if (target.charAt(i-1) != reverseTarget.charAt(j-1)) { + dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]); + } else { + dp[i][j] = dp[i-1][j-1] + 1; + } + } + } + + System.out.println(N-dp[N][N]); + } +} + +```