https://www.acmicpc.net/problem/1371
const fs = require('fs');
let input = fs.readFileSync('/dev/stdin').toString().split('\n');
const dic = {};
input.forEach(i => {
let arr = i.split("").filter(d => d !== ' ');
arr.forEach((a) => {
if(dic[a] === undefined) {
dic[a] =1;
} else {
dic[a] +=1;
}
})
}) ;
const keys = Object.keys(dic);
let answer = [];
keys.forEach(k => {
answer.push([k, dic[k]]);
});
answer.sort(function(a,b){
return b[1] - a[1];
})
const max = answer[0][1];
answer = answer.filter(a => a[1] === max);
const print =[];
answer.forEach(a => {
print.push(a[0]);
});
print.sort();
console.log(print.join(''));
728x90
'Algorithm\CodingTest > Baekjoon' 카테고리의 다른 글
[Baekjoon] [2754] 학점 계산 (0) | 2023.02.24 |
---|---|
[Baekjoon] [2566] 브론즈3 - 최댓값 Node.js (0) | 2023.02.24 |
[Beakjoon] [1427] 정렬 - 소트인사이드 (0) | 2023.02.24 |
[Baekjoon] [11650] 실버5 - 좌표 정렬하기 NodeJs (0) | 2023.02.24 |
[Baekjoon] [10828] 스택/큐 - 스택 (0) | 2023.02.24 |