[HoonDongKang] Week 8 solutions#1492
Merged
HoonDongKang merged 5 commits intoDaleStudy:mainfrom May 24, 2025
Merged
Conversation
Jeehay28
approved these changes
May 23, 2025
Contributor
Jeehay28
left a comment
There was a problem hiding this comment.
한 주 동안 문제 푸시느라 정말 고생 많으셨어요! 다음 주도 같이 힘내서 화이팅입니다! 😊
| */ | ||
| function characterReplacement(s: string, k: number): number { | ||
| //시간복잡도 O(n) | ||
| //공간복잡도 O(n) |
Contributor
There was a problem hiding this comment.
map에는 최대 26개의 알파벳만 key로 들어가므로, 공간 복잡도는 O(1)로 간주할 수 있습니다.
| map.set(s[right], (map.get(s[right]) || 0) + 1); | ||
|
|
||
| const maxFreq = Math.max(...Array.from(map.values())); | ||
| if (right - left + 1 - maxFreq > k) { |
Contributor
There was a problem hiding this comment.
right 포인터가 한 칸씩만 움직이기 때문에, 조건이 깨질 때 left 포인터도 한 칸씩만 이동해도 충분하다는 점을 이해하게 되었습니다. 저는 이 부분을 while 문으로 처리했었는데, if 문으로 처리해도 결과가 동일하게 나온다는 것을 확인했습니다. 감사합니다! 👍
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 하나 이상을 반드시 검토를 해주셔야 합니다!