-
Notifications
You must be signed in to change notification settings - Fork 125
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
[gitsunmin] Week3 Solutions #400
Conversation
|
||
export function climbStairs(n: number): number { | ||
if (n <= 2) return n; | ||
return upStairs(n); |
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.
안녕하세요 @gitsunmin 님! 고생하셨습니다!
array를 활용한 값 교환 좋네요!
그런데 두 함수의 입출력이 동일하고 단일 호출임에도 별도의 함수로 분리하신 건 각각의 함수가 하나의 태스크만 수행하도록 만들고자 하는 의도이셨을까요?
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.
저도 왜 굳이 3줄의 코드를 별도의 함수로 분리하셨는지 궁금해지네요 ㅎㅎ
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.
/** | ||
* https://leetcode.com/problems/product-of-array-except-self | ||
* time complexity : O(n) | ||
* space complexity : 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.
return을 위한 answer 배열을 위해 O(n)만큼의 공간을 소모하지 않을까요?
함수 주석에 문제 주소를 넣어주시니 리뷰하기가 정말 편리하네요. 저도 이렇게 해봐야겠습니다 ㅎㅎ
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.
return을 위한 answer 배열을 위해 O(n)만큼의 공간을 소모하지 않을까요?
@HC-kang 코딩 테스트에서는 입력/결과값에 필요한 메모리는 공간 복잡도 분석할 때 제외하는 경우가 많은 것 같습니다. 아무리 좋은 알고리즘을 써도 바꿀 수 없는 부분이니까요. 이 부분에 대해서 오해가 없도록 면접관과 의사소통하는 것도 중요하겠습니다.
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.
@DaleSeo 오, 그런가요? 답변해주셔서 감사합니다!
확실히 이 부분은 면접관과 의사소통이 중요할것같네요. 그렇지 않으면 아래 두 함수의 공간복잡도가 같아지는 경우가 생기니 직관적으로 어려움이 생길것같아요.
(nums) => nums;
(nums) => nums.sort((a, b) => a - b);
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.
수고하셨습니다. 400번째 PR 축하드려요 🎊
/** | ||
* https://leetcode.com/problems/product-of-array-except-self | ||
* time complexity : O(n) | ||
* space complexity : 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.
return을 위한 answer 배열을 위해 O(n)만큼의 공간을 소모하지 않을까요?
@HC-kang 코딩 테스트에서는 입력/결과값에 필요한 메모리는 공간 복잡도 분석할 때 제외하는 경우가 많은 것 같습니다. 아무리 좋은 알고리즘을 써도 바꿀 수 없는 부분이니까요. 이 부분에 대해서 오해가 없도록 면접관과 의사소통하는 것도 중요하겠습니다.
|
||
export function climbStairs(n: number): number { | ||
if (n <= 2) return n; | ||
return upStairs(n); |
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.
저도 왜 굳이 3줄의 코드를 별도의 함수로 분리하셨는지 궁금해지네요 ㅎㅎ
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.