[20250830] BOJ / G4 / 고냥이 / 이강현 #774
Merged
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.
🧷 문제 링크
https://www.acmicpc.net/problem/16472
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
고냥이는 최대 N개의 문자 종류만 알아들을 수 있음. 이때 문자열 중에서 알아들을 수 있는 최대 문자열 길이를 출력
🔍 풀이 방법
투 포인터
left right 두 개의 포인터로 쭉 오른쪽으로 이동하면서 map을 통해 현재 문자 종류가 N을 넘어가지 않게끔 쭉 확인함.
⏳ 회고
반복문에서 현재 문자 종류가 N보다 작아야 받을 수 있게끔 했었는데 생각해보면 N개가 충족됐더라도 이미 있는 단어가 들어오는 경우에는 받을 수 있게 했어야 했다. 바로 생각을 못했던게 아쉽다.