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.
[bhyun-kim, 김병현] Week 6 solutions #118
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
[bhyun-kim, 김병현] Week 6 solutions #118
Changes from all commits
7eb6656
f8f7b5d
c653d51
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
배열에서 가장 많이 나타났던 수 max_freq 를 찾는 과정이에요. 문제에서 k 개수 만큼 변경을 허용하는 부분이 있는데, 윈도우의 길이에서 max_freq 를 빼면 변경해야하는 문자들의 수가 나오고, 이를 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.
앗, 질문의 의도가 잘못 전달이 되었군요. 저는 이 작업이 무엇을 하느냐를 여쭤본 게 아니라 왜 필요한지에 대해서 물어본 것입니다.
max_freq
를 여기서 왜 구하시나요? 어디다가 쓰시나요? 코드에서 그 게 잘 파악이 안 되서 여쭤봤습니다.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.
Sliding Window를 전개할 때 왼쪽 포인터를 전진시키는 조건으로 활용했습니다.
예를 들어,
s = "AABABBA", k = 1의 문제에서
현재 윈도우가 "AABA"라면 전체에서 가장 많이 나타나는 A의 빈도수를 빼면 남는 character의 수가 1이 됩니다. 이 때 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.
제가 코멘트를 남긴 부분은 line 42에 조건문이 아니라 line 47-49입니다.
역시서
max_freq
를 구하셨는데, 이 걸 어디에 활용하고 계신지 보이지 않아서 의아했습니다.이 세 줄의 코드를 삭제하시고 답안 코드를 리트코드에 제출해보시겠어요?
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.
해당 부분 삭제해서 제출했는데 Time Limit Exceeded가 뜹니다. left를 갱신한 이후에 max_freq를 변경해야 while 문에 대한 조건이 바뀌기 때문에 그런 것 같습니다.
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.
리뷰 날짜가 길어지는 것 같아서 일단 Resolve하고 Merge 하겠습니다. 혹시 더 이야기 나누실 부분 있으시면 알려주세요!