https://school.programmers.co.kr/learn/courses/30/lessons/17680
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
function solution(cacheSize, cities) {
const queue = [];
let runTime = 0;
cities.forEach(data => {
data = data.toLowerCase();
if (queue.includes(data)) {
queue.splice(queue.findIndex((e) => e === data), 1);
runTime++;
} else {
if (queue.length >= cacheSize) queue.shift();
runTime += 5;
}
if (cacheSize > 0) queue.push(data);
});
return runTime;
}
GitHub - developeSHG/Algorithm-Baekjoon_Programmers: 백준 and 프로그래머스 소스코드
백준 and 프로그래머스 소스코드. Contribute to developeSHG/Algorithm-Baekjoon_Programmers development by creating an account on GitHub.
github.com
'Coding Test > Programmers' 카테고리의 다른 글
[Programmers] Lv 2. 행렬의 곱셈 (0) | 2023.02.07 |
---|---|
[Programmers] (월간 코드 챌린지 시즌2) Lv 2. 괄호 회전하기 (0) | 2023.02.06 |
[Programmers] (정렬) Lv 2. H-Index (0) | 2023.02.04 |
[Programmers] (Summer/Winter Coding(~2018)) Lv 2. 점프와 순간 이동 (0) | 2023.02.03 |
[Programmers] (2017 팁스타운) Lv 2. 예상 대진표 (0) | 2023.02.01 |
댓글