[std-freejia] week 02 solutions#1753
Merged
SamTheKorean merged 4 commits intoDaleStudy:mainfrom Aug 3, 2025
Merged
Conversation
Contributor
Author
|
안녕하세요 @hj4645 님! 리뷰 부탁드려도 될까요 😀 |
Contributor
Author
|
안녕하세요 스터디 리더 @TonyKim9401 님! 😀 혹시 리뷰 부탁드려도 될까요? 감사합니다. |
hj4645
approved these changes
Aug 2, 2025
hj4645
approved these changes
Aug 2, 2025
Contributor
There was a problem hiding this comment.
이 문제는 맵을 하나만 선언해서 count를 빼주는 방식으로 풀었었는데, 2개를 선언해서 equals로 푸는 방법도 가독성 면에서 좋은 것 같습니다
2주차도 수고 많으셨습니다!😆
리뷰가 늦어 죄송합니다🥲
Map<Character, Integer> map = new HashMap<>();
// s의 문자로 카운트 증가
for (char c : s.toCharArray()) {
map.put(c, map.getOrDefault(c, 0) + 1);
}
// t의 문자로 카운트 감소
for (char c : t.toCharArray()) {
int count = map.getOrDefault(c, 0);
if (count == 0) { // t에만 있는 문자가 있거나, 같은 문자가 더 많으면
return false;
}
map.put(c, count - 1);
}
return true;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!