-
-
Notifications
You must be signed in to change notification settings - Fork 195
[mintheon] Week 1 #633
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
[mintheon] Week 1 #633
Conversation
안녕하세요 @mintheon 님! |
|
||
PriorityQueue<Entry<Integer, Integer>> pq = new PriorityQueue<>((a, b) -> b.getValue().compareTo(a.getValue())); | ||
pq.addAll(frequent.entrySet()); | ||
|
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.
PriortyQueue랑 정렬은 시간 복잡도는 O(nlogn)으로 동일하지만, 상위 k개 요소를 구할 때는 PriorityQueue가 더 효율적이겠네요! 하나 배워갑니다 :)
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.
PriorityQueue<Entry<Integer, Integer>> pq = new PriorityQueue<>((a, b) -> b.getValue().compareTo(a.getValue())); | ||
pq.addAll(frequent.entrySet()); |
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.
가장 큰 수 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.
가장 큰 수 k개만 필요한데 반드시 모든 숫자를 정렬해야할까를 고민해보시면 보다 효율적인 알고리즘을 얻으실 수도 있을 것 같습니다.
올려주신 풀이의 배열 방법은 생각치 못했어요.
다만 자바로 변환해서 푸니 List<List<>> 방식이 되어 코드가 복잡해지는 경향이 있는것 같아요. 그래도 속도는 확실하네요!! 👍🏻
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.