Skip to content
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

Merged
merged 5 commits into from
Aug 31, 2024
Merged

[gitsunmin] Week3 Solutions #400

merged 5 commits into from
Aug 31, 2024

Conversation

gitsunmin
Copy link
Contributor

@gitsunmin gitsunmin commented Aug 30, 2024

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@gitsunmin gitsunmin requested a review from JEONGHWANMIN August 30, 2024 14:58
@gitsunmin gitsunmin self-assigned this Aug 30, 2024
@gitsunmin gitsunmin requested a review from a team as a code owner August 30, 2024 14:59
@github-actions github-actions bot added the ts label Aug 30, 2024
@DaleSeo
Copy link
Contributor

DaleSeo commented Aug 30, 2024

묻지마 체크인가요? ㅎㅎ Week 설정이 안 되어 있는 것 같습니다!

Shot 2024-08-30 at 12 15 53@2x

@gitsunmin
Copy link
Contributor Author

묻지마 체크인가요? ㅎㅎ Week 설정이 안 되어 있는 것 같습니다!

Shot 2024-08-30 at 12 15 53@2x

그러게요.. ㅋㅋㅋㅋ 추가했습니다~! 🙏


export function climbStairs(n: number): number {
if (n <= 2) return n;
return upStairs(n);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요 @gitsunmin 님! 고생하셨습니다!

array를 활용한 값 교환 좋네요!

그런데 두 함수의 입출력이 동일하고 단일 호출임에도 별도의 함수로 분리하신 건 각각의 함수가 하나의 태스크만 수행하도록 만들고자 하는 의도이셨을까요?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 왜 굳이 3줄의 코드를 별도의 함수로 분리하셨는지 궁금해지네요 ㅎㅎ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HC-kang
처음에 했을 때 너무 오래 걸려서 통과를 못 했었는데, 그걸 고치는 과정에서 이런 방법을 찾게됬어요!

(@DaleSeo)
함수를 분리한 의도는 네넵 말씀하신 의도가 있긴했습니다.
사실은 분리 안 해도 상관 없긴 했는데, 함수명이 왠지 너무 강해보여서.. 바꾸고 싶었어요

/**
* https://leetcode.com/problems/product-of-array-except-self
* time complexity : O(n)
* space complexity : O(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return을 위한 answer 배열을 위해 O(n)만큼의 공간을 소모하지 않을까요?

함수 주석에 문제 주소를 넣어주시니 리뷰하기가 정말 편리하네요. 저도 이렇게 해봐야겠습니다 ㅎㅎ

Copy link
Contributor

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 코딩 테스트에서는 입력/결과값에 필요한 메모리는 공간 복잡도 분석할 때 제외하는 경우가 많은 것 같습니다. 아무리 좋은 알고리즘을 써도 바꿀 수 없는 부분이니까요. 이 부분에 대해서 오해가 없도록 면접관과 의사소통하는 것도 중요하겠습니다.

Copy link
Contributor

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);

Copy link
Contributor

@DaleSeo DaleSeo left a 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)
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 왜 굳이 3줄의 코드를 별도의 함수로 분리하셨는지 궁금해지네요 ㅎㅎ

@gitsunmin gitsunmin merged commit 1265a74 into DaleStudy:main Aug 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants