From a50f3f70e92e0fd0b91a0c23a63c627c173ef313 Mon Sep 17 00:00:00 2001 From: sey2 <54762273+sey2@users.noreply.github.com> Date: Mon, 29 Aug 2022 14:49:41 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=80=EB=A6=AC=20=EB=9B=B0=EA=B8=B0=20-=20l?= =?UTF-8?q?evel2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- programmers/LongJump.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 programmers/LongJump.java diff --git a/programmers/LongJump.java b/programmers/LongJump.java new file mode 100644 index 0000000..08c07a2 --- /dev/null +++ b/programmers/LongJump.java @@ -0,0 +1,13 @@ +class Solution { + public long solution(int n) { + long dp[] = new long[20001]; + dp[1] = 1; dp[2]=2; dp[3]=3; + + if(n<=3) return dp[n]; + + for(int i=4; i<=n; i++) + dp[i] = (dp[i-2] + dp[i-1]) % 1234567; + + return dp[n]; + } +}