Skip to content

Conversation

@Hong-Study
Copy link

@Hong-Study Hong-Study commented Nov 12, 2025

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@Hong-Study Hong-Study moved this from Solving to In Review in 리트코드 스터디 6기 Nov 15, 2025
Copy link

@Seoya0512 Seoya0512 left a comment

Choose a reason for hiding this comment

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

안녕하세요,
먼저 제가 C++ 코드는 잘 몰라서 코드 리뷰 진행에 도움이 됐는지 모르겠네요 🥹
그리고 Time Complexity, Space Complexity 결과도 함께 작성해주시면 더 좋을 것 같아요.
저도 원래 적지 않았는데 복잡도 계산 결과와 왜 그렇게 나왔는지 작성하니깐 개인적인 부분에서도 많은 도움이 되더라구요!!

그럼 이번 주 문제들 푸시느라 정말 고생 많으셨고, 다음주도 화이팅입니다 💪👍

class Solution {
public:
int longestConsecutive(vector<int>& nums) {
std::set<int> sorts{nums.begin(), nums.end()};

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) 이 나온다고 하더라고요.
set을 unordered로 사용해서 연속되는 숫자의 길이를 측정할 수 있도록 풀어보시는 것은 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

한번 참고해서 해볼게요 ㅎㅎ 감사합니다!

return true;
}

map[num] = 1;

Choose a reason for hiding this comment

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

map[num] = 1 로 value를 1로 지정하신 이유가 있을까요?
단순히 키 값의 존재 여부를 표시하기 위한 값일까요??

Copy link
Author

Choose a reason for hiding this comment

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

넵넵 단순 키 값의 존재여부를 표시하기 위함입니다. 지금 생각해보면 map이 아닌 set을 써도 됬었네요 ㅎㅎ

int longestConsecutive(vector<int>& nums) {
std::set<int> sorts{nums.begin(), nums.end()};

// 개선 필요...

Choose a reason for hiding this comment

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

어떤 점이 개선이 필요할지, 고민되는 것이 무엇인지 알려주시면 리뷰어가 함께 고민해줄 수 있을 것 같아요~!

Copy link
Author

Choose a reason for hiding this comment

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

사이트에서 속도가 50% 이하로 나와서 시간 복잡도 개선이 필요하다는 내용이였습니다! 다음에는 참고하여 디테일하게 적어볼게요 ㅎㅎ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants