[20251103] PGM / Lv2 / [1차] 뉴스 클러스터링 / 이강현 #1305
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://school.programmers.co.kr/learn/courses/30/lessons/17677
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
문자열 두개를 비교하는데 두글자씩 잘라서 자카드 유사도를 측정
france면 {fr,ra,an,nc,ce} 이렇게 집합을 생성하게 됨.
이때, 영어 대소문자는 비교하지 않고 그외 문자들은 모두 무시함.
예를 들어, ab+c라는 문자열이 있다면 집합은 {ab,bc}임.
이때 교집합을 합집합으로 나눈 값이 자카드 유사도임.
중복도 포함임. 그래서 {1,1,1}과 {1,1,1,1,1}은 교집합이 {1,1,1}이고 합집합이 {1,1,1,1,1}임.
자카드 유사도에 65536를 곱하고 소수점을 버린 형태로 출력.
🔍 풀이 방법
문자열
그냥 구현하라는대로 했다. substring으로 두 글자씩 뽑아서 리스트에 저장하고 정렬해서 앞에서부터 하나씩 비교함.
합집합은 두 집합의 크기를 더하고 교집합을 빼는 방식으로 구현함. 다중집합을 허용하기에
⏳ 회고
문자열 처리는 까다롭다.