데일리 루틴
57번 - 모의고사
https://school.programmers.co.kr/learn/courses/30/lessons/42840
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
function solution(answers) {
var answer = [];
const no1 = [1,2,3,4,5];
const no2 = [2,1,2,3,2,4,2,5];
const no3 = [3,3,1,1,2,2,4,4,5,5];
let grade1 = 0;
let grade2 = 0;
let grade3 = 0;
for(let i=0; i<answers.length; i++){
if(answers[i] === no1[i%no1.length])
grade1++;
if(answers[i] === no2[i%no2.length])
grade2++;
if(answers[i] === no3[i%no3.length])
grade3++;
}
let maxGrade = Math.max(grade1, grade2, grade3);
if(maxGrade === grade1)
answer.push(1);
if(maxGrade === grade2)
answer.push(2);
if(maxGrade === grade3)
answer.push(3);
return answer;
}
'TIL' 카테고리의 다른 글
[프로그래머스] MySQL - 12세 이하인 여자 환자 목록 출력하기 (0) | 2024.09.23 |
---|---|
[프로그래머스] MySQL - 가장 큰 물고기 10마리 구하기 (0) | 2024.09.23 |
9/5 TIL (1) | 2024.09.05 |
9/4 TIL (0) | 2024.09.04 |
9/3 TIL (0) | 2024.09.03 |