Skip to content

Conversation

@devyulbae
Copy link
Contributor

@devyulbae devyulbae commented Nov 14, 2025

답안 제출 문제

  • Two Sum
  • Contains Duplicate
  • Top K Frequent Elements
  • Longest Consecutive Sequence
  • House Robber (not solved)

@devyulbae devyulbae self-assigned this Nov 14, 2025
@github-actions github-actions bot added the py label Nov 14, 2025
@devyulbae devyulbae moved this from Solving to In Review in 리트코드 스터디 6기 Nov 14, 2025
@devyulbae devyulbae requested review from hyunolike and removed request for hyunolike November 14, 2025 10:28
@8804who 8804who self-requested a review November 14, 2025 13:19
@8804who
Copy link
Contributor

8804who commented Nov 14, 2025

안녕하세요!

  1. Two Sum
  • 2중첩 중복문을 쓰는 대신 1단 중복문을 사용하여 숫자들을 순서대로 조회
  • 해시맵을 사용해 반복문을 돌며 등장한 숫자들을 기록(key: 숫자, value: 해당 숫자의 인덱스) 저장
  • 구해야 할 값 - 현재 숫자가 해시맵 내에 존재할 경우 해당 숫자의 인덱스와 현재 숫자의 인덱스를 출력
  • 위 방법을 통해 O(N)의 시간복잡도로 문제를 해결할 수 있습니다.
  1. Contains Duplicate
  • 단순히 중복을 제거하는 용도라면 Counter 대신에 set을 사용하는 것을 추천드립니다
  1. Top K Frequent Elements
  • 저와 동일한 방식으로 푸셨네요!
  1. Longest Consecutive Sequence
  • sort는 시간복잡도가 O(n log n)이므로 시간초과가 발생합니다
  • 숫자를 O(1)으로 검색 가능할 수 있도록 해시맵이나 set을 사용
  • 현재 범위보다 1만큼 크거나 작은 수가 존재할 경우 범위를 늘려가며 연속된 숫자의 수를 세는 방식으로 O(n) 시간 내에 문제를 해결할 수 있습니다
  1. House Robber

Copy link
Contributor

@8804who 8804who left a comment

Choose a reason for hiding this comment

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

👍

@devyulbae
Copy link
Contributor Author

<린트 에러 수정 완료>

@devyulbae devyulbae requested a review from 8804who November 15, 2025 11:49
@devyulbae
Copy link
Contributor Author

@DaleStudy 리뷰해줘

@dalestudy
Copy link
Contributor

dalestudy bot commented Nov 15, 2025

좋은 작업입니다! 여러 문제를 해결하며 다양한 접근법을 시도한 점이 인상적입니다. 특히, 각 문제의 시간복잡도와 개선 가능성에 대해 고민하고 계신 부분이 돋보입니다.

몇 가지 피드백 드리자면:

  1. 시간/공간 복잡도 명시: 각 솔루션에 TC와 SC를 명시하면, 더 명확한 이해와 비교가 가능해집니다. 예를 들어, containsDuplicate는 현재 Counter 사용으로 O(n) 시간과 공간 복잡도를 가지며, longestConsecutiveSequence는 정렬 기반이기 때문에 O(n log n)임을 명확히 표기하는 것이 좋습니다.

  2. House Robber 문제: 현재 재귀 + 메모이제이션 방식인데, 이 접근법은 시간복잡도 O(n)으로 최적입니다. 다만, 주석에 언급된 것처럼 재귀는 비효율적이므로, DP 방식으로 변경하는 것도 추천합니다. DP 버전은 가독성도 높고, 반복문으로 구현 가능하여 성능 향상에 도움이 될 것입니다.

  3. longestConsecutiveSequence: 정렬 기반 해결책은 O(n log n)이 소요되며, 문제 조건에 따라 O(n) 솔루션이 더 적합합니다. 집합(set)을 활용하는 방식이 더 효율적입니다(즉, 시작점인지 체크 후 연속된 수 찾기). 이를 고려해보세요.

  4. 가독성과 스타일: 함수와 변수 명은 직관적이고 깔끔합니다. 다만, 주석에 간략한 설명과 시간복잡도 표기를 추가하면 더 체계적일 것 같습니다.

종합적으로, 이미 좋은 방향으로 구현하고 계시며, 조금 더 효율적인 알고리즘과 명시적 복잡도 표기를 통해 더 발전시킬 수 있습니다. 계속해서 다양한 문제를 도전하는 모습이 멋집니다. 응원할게요!

Copy link
Contributor

@8804who 8804who left a comment

Choose a reason for hiding this comment

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

Good

@8804who 8804who moved this from In Review to Completed in 리트코드 스터디 6기 Nov 15, 2025
@8804who 8804who moved this from Completed to In Review in 리트코드 스터디 6기 Nov 15, 2025
@8804who 8804who self-requested a review November 15, 2025 12:27
@8804who
Copy link
Contributor

8804who commented Nov 15, 2025

👍

@8804who 8804who removed their request for review November 15, 2025 12:29
Copy link
Contributor

@8804who 8804who left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@8804who 8804who left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@8804who 8804who left a comment

Choose a reason for hiding this comment

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

👍

@devyulbae devyulbae merged commit 208447d into DaleStudy:main Nov 15, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 6기 Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants