Skip to content

[SunaDu] Week 13 #1073

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 7 commits into from
Mar 8, 2025
Merged

[SunaDu] Week 13 #1073

merged 7 commits into from
Mar 8, 2025

Conversation

dusunax
Copy link
Member

@dusunax dusunax commented Mar 3, 2025

답안 제출 문제

Week 13

체크 리스트

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

@dusunax dusunax self-assigned this Mar 3, 2025
@dusunax dusunax requested a review from a team as a code owner March 3, 2025 12:06
@github-actions github-actions bot added the py label Mar 3, 2025
@dusunax dusunax requested a review from bus710 March 3, 2025 12:06
intervals.sort(key=lambda x: x[0])

for i in range(1, len(intervals)):
if intervals[i][0] < intervals[i-1][1]:
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
Member Author

Choose a reason for hiding this comment

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

회의 시작시간 기준으로 오름차순 정렬한 이후
시작시간과 끝나는 시간을 비교하기 때문에
모든 회의를 처리할 수 있습니다🤔

예를 들어 [[1, 5], [6, 7], [4, 10]]인 입력이 있으면
26번째 라인에서 [[1, 5], [4, 10], [6, 7]]로 정렬하기 때문에 겹침을 확인할 수 있어요~

Copy link
Member Author

@dusunax dusunax Mar 5, 2025

Choose a reason for hiding this comment

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

달레님이 더 잘 설명해주신 것 같아 링크 남깁니다🙂
https://www.algodale.com/problems/meeting-rooms/#%ED%92%80%EC%9D%B4-2-%EC%A0%95%EB%A0%AC

Comment on lines +24 to +29
class Solution:
def canAttendMeetings(self, intervals: List[List[int]]) -> bool:
intervals.sort(key=lambda x: x[0])

for i in range(1, len(intervals)):
if intervals[i][0] < intervals[i-1][1]:
Copy link
Contributor

Choose a reason for hiding this comment

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

안녕하세요 @dusunax 님! 저도 같은 방식으로 문제를 풀었는데, 제 코드보다 훨씬 간결해서 참고가 되었습니다 👍

Copy link
Member Author

@dusunax dusunax Mar 7, 2025

Choose a reason for hiding this comment

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

네 감사합니다☺️

@KwonNayeon풀이하고 거의 동일한데 제 풀이는 딱 intervals의 길이만큼 순회하는 구조라서,
배열길이가 0일 시 intervals[0].end에 접근하지 않으니까 키 에러가 나지 않고, 얼리리턴이 필요없었어요.

for interval in intervals[1:]:

그리고 intervals[1:]은 슬라이싱하면서 새 리스트를 만드니까 인덱스 루프로만 진행하는 것이 성능상의 이점도 있어요!

다만 얼리리턴은 Constraints에서 intervals.length가 0일 수 있다. 라고 했기 때문에 실제 개발에서 나연님처럼 if not intervals: return True를 명시적으로 표현하는 것도 개발자의 의도를 드러내는 좋은 습관이라고 생각합니다~

Copy link
Contributor

Choose a reason for hiding this comment

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

와 자세한 설명 감사합니다 🤩 그냥 문제만 풀고 넘어갔으면 이렇게 디테일한 것까지 생각할 기회가 없었을 것 같아요. 선아님이 제 코드와의 다른 점들을 쉽게 설명해주셔서 이해가 쉬웠습니다!

@dusunax dusunax moved this from Solving to In Review in 리트코드 스터디 3기 Mar 8, 2025
@dusunax
Copy link
Member Author

dusunax commented Mar 8, 2025

@bus710 @TonyKim9401
In Review로 변경했는데 혹시 PR 리뷰 & 승인 부탁드려도 될까요?

@dusunax dusunax merged commit 0fa58c9 into DaleStudy:main Mar 8, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 3기 Mar 8, 2025
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.

4 participants