-
-
Notifications
You must be signed in to change notification settings - Fork 305
[deepInTheWoodz] WEEK 02 Solutions #2053
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
Conversation
seungriyou
left a comment
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.
이번 한 주도 고생 많으셨습니다! 😆
| @@ -0,0 +1,12 @@ | |||
| # TC: O(1) | |||
| # SC: O(1) | |||
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.
현재 코드에서는 시간 & 공간 복잡도가 모두 O(n)인 것으로 보입니다!
| dp[2] = 2 | ||
|
|
||
| for i in range(3, n+2): | ||
| dp[i] = dp[i-1] + dp[i-2] |
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.
이렇게 DP 테이블의 가장 최근 n개의 원소만 사용하는 경우에는 O(n) space의 DP 테이블 대신 O(1)space의 변수를 사용해서 공간 복잡도를 한 단계 최적화 할 수 있을 것 같아요~!
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!