Skip to content

Conversation

@samcho0608
Copy link
Contributor

@samcho0608 samcho0608 commented Nov 11, 2025

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@se6816 se6816 self-requested a review November 11, 2025 23:48
@samcho0608 samcho0608 moved this from Solving to In Review in 리트코드 스터디 6기 Nov 12, 2025
Comment on lines +10 to +12
for(int num : nums) {
if(!uniqNums.add(num)) 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.

저는 set 내 값 체크 유무를 contains() 메소드를 주로 떠올리는데,
HashSet의 add() 메소드 리턴 값을 이용하신 부분에서 인상깊었습니다.

@samcho0608
Copy link
Contributor Author

@DaleStudy

@dalestudy
Copy link
Contributor

dalestudy bot commented Nov 14, 2025

Great job on submitting multiple solutions across different problems! Your code is clear, well-commented, and demonstrates good understanding of the algorithms. Here are some constructive suggestions to further improve your work:

  1. Time and Space Complexity Annotations:
    You’ve added complexity comments in some solutions, which is excellent. For consistency, consider including them across all solutions, especially in the rob problem. For example, the rob function has a nested loop that could be optimized; explicitly stating the overall TC and SC would help reviewers grasp your thought process.

  2. Algorithmic Improvements:

    • In the rob solution, your current implementation considers only i-2 and i-3. A more standard approach uses dynamic programming with maxSum[i] = Math.max(maxSum[i-1], maxSum[i-2] + nums[i]). This simplifies the logic and ensures correctness, especially for larger inputs.
    • For the longestConsecutive problem, your approach is good, but it could be optimized further by only expanding sequences from the start points (numbers without a predecessor). You’ve done this, which is great, but emphasizing that it achieves O(N) time due to avoiding repeated work would be helpful.
  3. Code Readability & Style:

    • Consistent indentation and spacing are maintained well.
    • In the topKFrequent solutions, the variable naming is clear, but adding brief comments about the bucket sort approach can make it even more accessible.
  4. Additional Tips:

    • Consider handling edge cases explicitly, such as empty arrays or small input sizes, even if they are implicitly covered.
    • For the twoSum problem, you might optimize by constructing the map on-the-fly in a single pass, reducing the total time complexity to O(n) without two separate loops.

Overall, your solutions are solid, and with some refinements, they can be even more efficient and easier to follow. Keep up the excellent work — your understanding of these algorithms is evident, and your consistent commenting shows good coding practices.


// count till end of consecutive sequence
int len = 1;
for(int i = 1; uniq.contains(num + i); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

해당 부분에서 i 값이 따로 쓰이지 않아서 while문으로 작성하는 것도 나쁘지 않을 것 같습니다.

while(uniq.contains(num + i)) {
    len++;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

조건문이 i를 포함하고 있어서 사용하긴 해야합니다!

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 +15 to +21
PriorityQueue<int[]> heap = new PriorityQueue<>(Comparator.comparingInt(a -> a[1]));
for(int num : freq.keySet()) {
int f = freq.get(num); // O(1)
heap.add(new int[]{num, f}); // O(log k)

if(heap.size() > k) heap.poll(); // O(log k)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

PriorityQueue 내 요소 개수를 k개로 유지해서, O(NlogN)이 아닌 O(Nlogk)로 하신 방법이 흥미롭네요.

@samcho0608 samcho0608 merged commit 804af96 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

Labels

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants