Skip to content

[bus710] Week 07 #928

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

Merged
merged 1 commit into from
Jan 24, 2025
Merged

[bus710] Week 07 #928

merged 1 commit into from
Jan 24, 2025

Conversation

bus710
Copy link
Contributor

@bus710 bus710 commented Jan 20, 2025

답안 제출 문제

체크 리스트

  • 우측 메뉴에서 PR을 Projects에 추가해주세요.
  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@bus710 bus710 requested a review from a team as a code owner January 20, 2025 01:50
@github-actions github-actions bot added the go label Jan 20, 2025
@bus710 bus710 requested a review from lledellebell January 20, 2025 01:50
@bus710
Copy link
Contributor Author

bus710 commented Jan 20, 2025

문제 1번의 경우 주어진 리스트를 쭉 순회하며 각 요소의 값을 새 요소에 복사한 후 그 새 요소의 next를 이 전에 생성했던 요소로 지정하는 방식을 사용함으로써 시간 복잡도를 O(n)으로 유지할 수 있도록 시도해봤습니다. 다만 그에 상응해 공간을 더 사용하게 되어서 공간 복잡도는 O(2n)이 되었습니다. 둘 다 만족하거나 상황에 따라 절충하는 방법을 찾으면 좋겠습니다.

나머지 풀이는 가급적 차차 추가하도록 하겠습니다.

@bus710
Copy link
Contributor Author

bus710 commented Jan 23, 2025

시간이 통 안나네요 ㅠㅠ
리뷰 진행 부탁 드립니다.

Copy link
Contributor

@obzva obzva left a comment

Choose a reason for hiding this comment

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

바쁘시죠? 한 문제라도 푸시려는 모습 멋집니다. 수고 많으십니다!

@@ -0,0 +1,26 @@
package hello
Copy link
Contributor

Choose a reason for hiding this comment

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

안녕하세요 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

문제 풀이를 할 때 테스트를 먼저 작성하는 편인데, 패키지 이름을 짧게 적다보니 이렇게 되었습니다 ㅎㅎ

Comment on lines +9 to +13
head2 := &ListNode{}

if head == nil {
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

숏컷 로직이 제일 상단에 위치하는게 좋을 것 같아요

Suggested change
head2 := &ListNode{}
if head == nil {
return nil
}
if head == nil {
return nil
}
head2 := &ListNode{}

Copy link
Contributor

Choose a reason for hiding this comment

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

그리고 head2보다 더 나은 이름이 있을 것 같아요
이 변수가 뭐하는 녀석인지 바로 와닿지가 않았습니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

그렇네요, 할당 하기 전에 반환하는게 더 나을 것 같습니다.
반환하는 변수 이름도 신경 쓰겠습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

반복문 내에서 계속 새로운 ListNode struct instance를 생성하는 것은 공간 복잡도 측면에서 효율적이지 않습니다
포인터만을 이용하는 것을 추천드립니다 :)
제가 제안하는 솔루션 또한 첨부합니다, 정 생각이 안 나시거나 바쁘실 때 참고해주세요 (https://gist.github.com/obzva/c5f726474e844e076270aad523acc39e)

@bus710 bus710 merged commit 5d393ea into DaleStudy:main Jan 24, 2025
3 checks passed
@bus710 bus710 deleted the week07 branch January 24, 2025 19:43
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.

2 participants