Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
문제
Constraints
n<= 45Edge Case
풀이
1 step과 2 step의 합을 이용하여 n까지 이동하여야 하는 문제로, N = 4일 때 까지를 구해보면 다음과 같습니다.
즉, 위 문제에서 다음과 같이 공식을 만들 수 있습니다.
n = k일 때, f(k) = f(k-1)에서 1만큼 이동하기 + f(k-2)에서 2만큼 이동하기Important
1 Step과 2 Step의 합으로 이루어져야 한다면, 결국 1 Step 전의 수와 2 Step 전의 수의 합과 동일하다.
어려웠던 점
문제에서 주어진 패턴은 피보나치 수열로, n = 4일 때까지만 구해보면 쉽게 도출해낼 수 있습니다. 하지만 이것이 왜 피보나치 수열인지, 완전한 이해를 하는 데 생각보다 오래 걸렸던 것 같습니다.
알게된 점