-
-
Notifications
You must be signed in to change notification settings - Fork 305
[rivkode] WEEK 02 solutions #2045
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
|
@pastelto 제가 status 변경을 깜빡 했네요 ! 리뷰 부탁드립니다. 감사합니다! |
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.
문제를 풀이하면서 고민하셨던 점들을 기록해주셔서 저도 함께 고민해보면서 코드를 읽어볼 수 있었던 것 같아요!
이번 한 주도 고생 많으셨습니다~! 😁
| arr[1] = 2; | ||
|
|
||
| for (int i=2; i<45; i++) { | ||
| arr[i] = arr[i-1] + arr[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의 변수를 사용해서 공간 복잡도를 한 단계 최적화 할 수 있을 것 같아요~! (물론 이번 문제에서는 n <= 45 조건이 있기는 하지만요..!)
| bfs로 진행해보자 | ||
|
|
||
| 아니다 .. dfs가 맞네 하한 상한을 정해줘야 함 | ||
| 그리고 예외 케이스 있다 [-2147483648,null,2147483647] |
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.
엣지 케이스에 대해서도 분석하신 점이 인상깊습니다!!
| 아니다 .. dfs가 맞네 하한 상한을 정해줘야 함 | ||
| 그리고 예외 케이스 있다 [-2147483648,null,2147483647] | ||
|
|
||
| 처음에 하한과 상한을 MIN_VALUE, MAX_VALUE를 통해 사용하고 있었는데 위 엣지 케이스를 발견 |
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.
저는 DFS로 이 문제에 접근할 때 상한/하한을 넣어줘야 하는 부분에서 헤맸었는데요,
대신 BST는 inorder 순회를 하면 오름차순 정렬이 된다는 점에 착안해서도 문제를 풀어보았습니다!
다른 풀이 방법도 슬쩍 공유드려요~!
|
늦어서 죄송합니다. 제가 여행 중이었어서 이제서야 리뷰를 남깁니다..! 주석으로 문제 접근 방식과 어떻게 해결해 나가셨는지 적어주신 점이 인상 깊습니다. |
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!