-
-
Notifications
You must be signed in to change notification settings - Fork 195
[박종훈] 5주차 답안 제출 #102
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
[박종훈] 5주차 답안 제출 #102
Conversation
3e7d5e7
to
954fece
Compare
@@ -0,0 +1,52 @@ | |||
- 문제 : https://leetcode.com/problems/3sum/ | |||
- time complexity : O(n^2) | |||
- space complexity : O(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.
저는 이부분이 궁금했는데 결과값을 고려하지 않는다는 걸 따로 명시하지 않아도 결과값을 고려하지 않는게 당연한 걸까요?
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.
아 그렇군요! 설명 감사합니다!
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.
출력 결과 때문에 반드시 필요한 메모리 사용량은 공간 복잡도 분석을 할 때는 무시하는 것이 일반적입니다.
커밋이 사라지면 자동으로 closed로 바뀌군요 ㄷㄷ... |
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.
수고하셨어용!
- space complexity : O(n) | ||
- 블로그 링크 : https://algorithm.jonghoonpark.com/2024/05/08/leetcode-238 | ||
|
||
## case 나눠서 풀기 |
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.
앗...! ㅋㅋ 주관적인 기준이였군요 ㅎㅎ
아래 풀이를 들었을 때 워낙 혁신이였어서 저는 재밌게 느꼈었네요...! ㅎㅎ
return Arrays.copyOfRange(counter.entrySet().stream() | ||
.sorted(Map.Entry.<Integer, Integer>comparingByValue().reversed()) | ||
.mapToInt(Map.Entry::getKey) | ||
.toArray(), 0, k); |
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.
자바 스크림 API 잘 쓰시네요!
5주차 답안 제출합니다.
Top K Frequent Elements
Encode and Decode Strings
Product of Array Except Self
Longest Consecutive Sequence
3Sum