s
순회true
, 그렇지 않다면 false
반환환function areOccurrencesEqual(s: string): boolean {
const frequent = new Map()
const firstChar = s[0]
let count = 0
for(let i = 0; i < s.length; i++) {
const char = s[i]
if(char === firstChar) count++
frequent.set(char, (frequent.get(char) ?? 0) + 1)
}
for(const [_, value] of frequent) {
if(value !== count) return false
}
return true
};