Skip to content

[yyyyyyyyyKim] WEEK 13 solutions #1614

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 6 commits into from
Jun 28, 2025
Merged

Conversation

yyyyyyyyyKim
Copy link
Contributor

@yyyyyyyyyKim yyyyyyyyyKim commented Jun 23, 2025

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@yyyyyyyyyKim yyyyyyyyyKim moved this from Solving to In Review in 리트코드 스터디 4기 Jun 27, 2025
Copy link
Contributor

@uraflower uraflower left a comment

Choose a reason for hiding this comment

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

설명이 필요한 부분마다 주석이 꼼꼼히 달려 있어 파이썬을 잘 모르는데도 읽는 데 지장이 없었어요.
또 제가 못 푼 문제의 접근 방법을 알아갈 수 있었습니다.
앞으로 2주 남았는데 마지막까지 파이팅하세요~~!

@@ -0,0 +1,27 @@
class MedianFinder:
# Follow up : 두 개의 heap 사용해서 구현 가능(시간복잡도 O(log n), 추가 공부 필요함)
# heap 사용하지 않고 이진 탐색 삽입으로 풀었음
Copy link
Contributor

Choose a reason for hiding this comment

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

제가 사용하는 자바스크립트에는 힙 같은 자료구조가 내장되어 있지 않아 힙을 직접 구현해야 해서 막막했는데, 이진 탐색 삽입으로 풀이하신 거 보고 저도 이진 탐색으로 풀 수 있었어요..! 감사합니다 👍

Comment on lines +23 to +31
# 시간복잡도(O(n^2)), 공간복잡도 O(1)
# 시작점을 기준으로 정렬(선택정렬)
for i in range(len(intervals)):
idx = i
for j in range(i+1,len(intervals)):
if intervals[j].start < intervals[idx].start:
idx = j
if idx != i:
intervals[i], intervals[idx] = intervals[idx], intervals[i]
Copy link
Contributor

Choose a reason for hiding this comment

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

내장 함수 sort를 사용하면 시간복잡도가 O(n log n)으로 더 효율적일 텐데, 내장 함수를 사용하지 않고 직접 선택 정렬을 구현하신 이유가 따로 있는 건가용?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

저는 LintCode에 있는 문제로 풀었는데, LintCode에는 intervals가 리스트가 아닌 클래스 객체라서 sort()로는 정렬이 안 된다고 생각했습니다. 그래서 속성에 직접 접근해서 정렬했습니다!
(람다함수로 key를 지정하면 클래스 객체도 sort()로 정렬할 수 있다는 걸 뒤늦게 깨달았습니다...)
리뷰 감사합니다!

@yyyyyyyyyKim yyyyyyyyyKim merged commit a68c8a4 into DaleStudy:main Jun 28, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 4기 Jun 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

2 participants