-
-
Notifications
You must be signed in to change notification settings - Fork 301
[Hong-Study] WEEK 01 solutions #1999
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
base: main
Are you sure you want to change the base?
Conversation
Seoya0512
left a comment
There was a problem hiding this 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()}; |
There was a problem hiding this comment.
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로 사용해서 연속되는 숫자의 길이를 측정할 수 있도록 풀어보시는 것은 어떨까요?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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로 지정하신 이유가 있을까요?
단순히 키 값의 존재 여부를 표시하기 위한 값일까요??
There was a problem hiding this comment.
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()}; | ||
|
|
||
| // 개선 필요... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어떤 점이 개선이 필요할지, 고민되는 것이 무엇인지 알려주시면 리뷰어가 함께 고민해줄 수 있을 것 같아요~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사이트에서 속도가 50% 이하로 나와서 시간 복잡도 개선이 필요하다는 내용이였습니다! 다음에는 참고하여 디테일하게 적어볼게요 ㅎㅎ
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!