[20250914] PGM / LV2 / 테이블 해시 함수 / 김수연 #893
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/147354
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
테이블의 튜플을 col번째 칼럼의 값 기준으로 오름차순 정렬하되, 값이 동일하면 기본키인 첫 번째 칼럼의 값 기준 내림차순 정렬
정렬된 데이터에서 S_i를 i번째 행의 튜플에 대해 각 컬럼의 값을 i로 나눈 나머지들의 합으로 정의
row_begin ≤ i ≤ row_end 인 모든 S_i를 누적하여 bitwise XOR 한 값을 해시 값으로서 반환
🔍 풀이 방법
단순 구현
2차원 배열을 정렬한 뒤, 각 행에서 해시처럼 값을 계산해 전부 XOR로 합쳐 하나의 숫자로 만들음
그 뒤 반복하면서 배열의 각 원소에 mod 연산한 뒤 총합 구함
⏳ 회고
^ 연산자 오랜만에 써봄,,