작은 값
,큰 값
형태의 문자열 구조로 빈도 확인function numEquivDominoPairs(dominoes: number[][]): number {
const history = new Map<string, number>()
let pairCount = 0
for(const [a, b] of dominoes) {
const format = a <= b ? `${a},${b}` : `${b},${a}`
history.set(format, (history.get(format) ?? 0) + 1)
}
for(const [key, value] of history) {
if(value < 2) continue
pairCount += value * (value - 1) / 2
}
return pairCount
};