영어 미번역 문제.
소들의 이름 목록을 먼저 정렬하고, JON 문자열로 만들어서 키 값으로 객체 카운트하여
객체의 값을 배열로 받아 그 중 최대값을 출력하였다
https://www.acmicpc.net/problem/9872
9872번: Record Keeping
Farmer John has been keeping detailed records of his cows as they enter the barn for milking. Each hour, a group of 3 cows enters the barn, and Farmer John writes down their names. For example over a 5-hour period, he might write down the following list, w
www.acmicpc.net
let input = [];
const readline = require("readline").createInterface({
input: process.stdin,
output: process.stdout,
});
readline.on("line", (line) => {
input.push(line);
});
readline.on("close", () => {
solution(input);
process.exit();
});
const solution = (inp) => {
inp.shift();
let oj = {};
for (el of inp) {
let str = JSON.stringify(el.split(" ").sort());
if (oj[str]) {
oj[str]++;
} else {
oj[str] = 1;
}
}
let ojvalue = Object.values(oj);
let ans = Math.max(...ojvalue);
console.log(ans);
};
'개발 노트 > 백준, 프로그래머스 풀이' 카테고리의 다른 글
[백준 1251/javascript] 단어 나누기 (0) | 2022.10.06 |
---|---|
[백준 2003/javascript] 수들의 합 2 (1) | 2022.10.04 |
[백준 1475/javascript] 방 번호 (0) | 2022.10.02 |
[백준 9655/javascript] 돌 게임 (0) | 2022.10.01 |
[백준 4659/javascript] 비밀번호 발음하기 (0) | 2022.09.30 |
댓글