-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Jay-Mo-99] Week 2 #733
Merged
Merged
[Jay-Mo-99] Week 2 #733
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#해석 | ||
#피보나치 수열을 이용하여 특정 범위마다 1과 2를 활용한 방법의 수를 계산한다. | ||
#a=1, a=2 로 초기 셋팅 후 반복문마다 a와 b를 업데이트 한다. | ||
# a는 현재 계단의 경우의 수, b는 다음 계단의 경우의 수로 설정한다. | ||
# 반복문의 결과로 n번째 계단을 오르는 방법의 수(a)를 반환한다. | ||
|
||
|
||
#Big O | ||
#N: 매개변수 n의 크기(계단 갯수) | ||
|
||
#Time Complexity: O(N) | ||
#- for loop 는 n-1번 : O(N) | ||
|
||
#Space Complexity: O(1) | ||
#- 상수 a,b만 사용 : O(1) | ||
|
||
class Solution(object): | ||
def climbStairs(self, n): | ||
""" | ||
:type n: int | ||
:rtype: int | ||
""" | ||
a,b = 1,2 #F(0) = 1, F(1) =2 | ||
for i in range(1,n): | ||
a,b = b, a+b #Update a and b each iteration | ||
#Fn = Fn-1 + Fn-2 | ||
|
||
return a | ||
|
Empty file.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파이썬의 강점이 잘 활용된것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
튜플할당 방식을 쓰니까 가독성이 좋네요! 처음 알게돼서 신기하네요 :)