-
Notifications
You must be signed in to change notification settings - Fork 126
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 5 #850
[mintheon] Week 5 #850
Conversation
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.
안녕하세요! 3개 문제 푸신 코드 잘 봤습니다. 풀이가 간결하고 깔끔하네요
저는 요즘 python으로 문제를 풀고 java로 변환하는 식으로 학습하고 있어요
잘 부탁드립니다🙂
/** | ||
시간복잡도: O(n) | ||
공간복잡도: O(n) | ||
*/ |
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.
for문 내부의 문자열 정렬이 O(k log k)이라서
전체 시간 복잡도는 O(n * k log k)로 수정하는 것이 더 정확할 것 같습니다:)
if(!anagramMap.containsKey(sortedStr)) { | ||
anagramMap.put(sortedStr, new ArrayList<>()); | ||
|
||
} | ||
|
||
anagramMap.get(sortedStr).add(str); |
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.
해시맵에서 키가 없는 경우 새로운 리스트를 생성하는 computeIfAbsent라는 메소드가 있더라구요.
코드를 간결하게 작성할 수 있어서 사용해보시는 걸 추천드립니다!
anagramMap.computeIfAbsent(key, k -> new ArrayList<>()).add(str);
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.