BOJ 1157

슬기로운 FE 세상·2022년 3월 19일
0

const input = require('fs').readFileSync('./input.txt').toString().trim()

let answer;
let alpha = input.toUpperCase()

const sH = new Map();

for(let x of alpha) {
    if(sH.has(x)) sH.set(x, sH.get(x) + 1)
    else sH.set(x, 1)
}

let max = Number.MIN_SAFE_INTEGER;

for(let [key, val] of sH) {
    if(val > max) {
        max = val;
        answer = key;
    }
    else if(val == max) {
        answer = '?'
    } 
}

console.log(answer);

new Map()을 통해서 key, val을 만들고 input의 데이터와 비교하여, 어떤게 가장 많은지 비교하여 출력

profile
자 드가자~~

0개의 댓글

관련 채용 정보