Skip to content

[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

Merged
merged 3 commits into from
Jun 10, 2024
Merged

Conversation

bhyun-kim
Copy link
Contributor

No description provided.

Copy link
Contributor

@SamTheKorean SamTheKorean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한 주도 고생많으섰습니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저랑 솔루션이 정확히 같으시네요~!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 다른 솔루션 찾다가 참고해서 풀었어요 ㅎㅎ

@DaleSeo
Copy link
Member

DaleSeo commented Jun 7, 2024

@bhyun-kim 님, Iteration 설정 좀 부탁드리겠습니다.

Comment on lines +47 to +49
max_freq = 0
for v in char_freq.values():
max_freq = max(v, max_freq)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 작업이 무슨 의미가 있을까요?

Copy link
Contributor Author

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와 비교하는 과정입니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗, 질문의 의도가 잘못 전달이 되었군요. 저는 이 작업이 무엇을 하느냐를 여쭤본 게 아니라 왜 필요한지에 대해서 물어본 것입니다. max_freq를 여기서 왜 구하시나요? 어디다가 쓰시나요? 코드에서 그 게 잘 파악이 안 되서 여쭤봤습니다.

Copy link
Contributor Author

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은 변경이 허용되는 횟수와 동일하기 때문에 현재 윈도우가 유효한 윈도우임을 판단합니다.

혹시.. 제가 질문 의도를 잘 이해한걸까요? 아니라면 한 번 더 알려주시면 감사드리겠습니다. 🙇

Copy link
Member

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를 구하셨는데, 이 걸 어디에 활용하고 계신지 보이지 않아서 의아했습니다.
이 세 줄의 코드를 삭제하시고 답안 코드를 리트코드에 제출해보시겠어요?

Copy link
Contributor Author

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 문에 대한 조건이 바뀌기 때문에 그런 것 같습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 날짜가 길어지는 것 같아서 일단 Resolve하고 Merge 하겠습니다. 혹시 더 이야기 나누실 부분 있으시면 알려주세요!

@bhyun-kim
Copy link
Contributor Author

@bhyun-kim 님, Iteration 설정 좀 부탁드리겠습니다.

또 깜빡했네요.. 설정했습니다!

Comment on lines +47 to +49
max_freq = 0
for v in char_freq.values():
max_freq = max(v, max_freq)
Copy link
Member

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를 구하셨는데, 이 걸 어디에 활용하고 계신지 보이지 않아서 의아했습니다.
이 세 줄의 코드를 삭제하시고 답안 코드를 리트코드에 제출해보시겠어요?

@bhyun-kim bhyun-kim merged commit 16d9ab3 into DaleStudy:main Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants