Skip to content

Conversation

bus710
Copy link
Contributor

@bus710 bus710 commented Jan 3, 2025

답안 제출 문제

체크 리스트

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

@bus710 bus710 requested a review from a team as a code owner January 3, 2025 08:03
@github-actions github-actions bot added the go label Jan 3, 2025
@bus710 bus710 changed the title week 04 [bus710] week 04 Jan 3, 2025
@bus710 bus710 requested a review from ekgns33 January 3, 2025 08:04
@bus710
Copy link
Contributor Author

bus710 commented Jan 3, 2025

한 문제만 풀어 제출합니다.
리뷰어분들께서는 바로 착수 해주시면 감사 드리겠습니다.

@bus710
Copy link
Contributor Author

bus710 commented Jan 3, 2025

공간 복잡도는 두개의 주어진 리스트가 차지하는 만큼 추가되므로 O(M+N)
시간 복잡도는 각 리스트의 값 분포에 따라 달라질 수 있는데, 만약 한 쪽이 짧으면서 그 값들도 반대쪽에 비해 비교적 작은 값들 뿐이라면 빠르게 병합이 될 수 있겠습니다. 빅O 표기로는 어떻게 해야할지 모르겠네요.

newList := &ListNode{}
cur := newList

for {
Copy link
Contributor

Choose a reason for hiding this comment

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

1-loop으로 잘 풀어내셨군요! 다음 제출부터 혹시 주석으로 time/space complexity를 적어주시면, 리뷰할때 도움이 될 것 같습니다 :)

  • 개인적인 궁금점 하나만 질문하자면 for vs while 중 이 문제에서 for을 사용하신 이유가 있으신가요? (개인적 취향에 가까워서 그냥 궁금합니다 🤣

Copy link
Contributor

@HC-kang HC-kang left a comment

Choose a reason for hiding this comment

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

@bus710 님, 고생하셨습니다.

공간 복잡도는 두개의 주어진 리스트가 차지하는 만큼 추가되므로 O(M+N) 시간 복잡도는 각 리스트의 값 분포에 따라 달라질 수 있는데, 만약 한 쪽이 짧으면서 그 값들도 반대쪽에 비해 비교적 작은 값들 뿐이라면 빠르게 병합이 될 수 있겠습니다. 빅O 표기로는 어떻게 해야할지 모르겠네요.

제 생각에, 우선 주어진 LinkedList를 포인터만 조정하여 풀이를 제출해 주셔서 추가적인 공간복잡도가 필요하지는 않아 보여요. 따라서 공간복잡도는 O(1)로 보이구요,
오히려 시간복잡도가, 결국은 모든 노드를 한번씩은 보아야 한다는 점에서 O(M+N)으로 보이네요!

@bus710 bus710 merged commit b8c3521 into DaleStudy:main Jan 3, 2025
3 checks passed
@bus710 bus710 deleted the week04 branch January 3, 2025 14:55
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