From 589e242c5c8b44cd6eb6722d50c498eb353293d3 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Fri, 12 Dec 2025 23:50:05 +0900 Subject: [PATCH] =?UTF-8?q?[20251212]=20PGM=20/=20Lv2=20/=20=ED=94=BC?= =?UTF-8?q?=EB=B3=B4=EB=82=98=EC=B9=98=20=EC=88=98=20/=20=EC=9D=B4?= =?UTF-8?q?=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\202\230\354\271\230 \354\210\230.md" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "lkhyun/202512/12 PGM Lv2 \355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" diff --git "a/lkhyun/202512/12 PGM Lv2 \355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" "b/lkhyun/202512/12 PGM Lv2 \355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" new file mode 100644 index 00000000..3b1ff801 --- /dev/null +++ "b/lkhyun/202512/12 PGM Lv2 \355\224\274\353\263\264\353\202\230\354\271\230 \354\210\230.md" @@ -0,0 +1,25 @@ +```java +class Solution { + private static final int MOD = 1234567; + private int[] memo; + + public int solution(int n) { + memo = new int[n + 1]; + return fib(n); + } + + private int fib(int n) { + if (n == 0) return 0; + if (n == 1) return 1; + + // 이미 계산된 값이 있으면 반환 + if (memo[n] != 0) { + return memo[n]; + } + + // 계산 후 메모에 저장 + memo[n] = (fib(n - 1) + fib(n - 2)) % MOD; + return memo[n]; + } +} +```