https://school.programmers.co.kr/learn/courses/30/lessons/17683
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
function solution(m, musicinfos) {
m = m.replaceAll('C#', 'c').replaceAll('D#', 'd').replaceAll('F#', 'f').replaceAll('G#', 'g').replaceAll('A#', 'a');
return musicinfos.reduce((acc, data) => {
const [start, end, TITLE, tempSheet] = data.split(',');
const getMin = (time) => parseInt(time[0]) * 60 + parseInt(time[1]);
const TIME = getMin(end.split(':')) - getMin(start.split(':'));
const sheet = tempSheet.replaceAll('C#', 'c').replaceAll('D#', 'd').replaceAll('F#', 'f').replaceAll('G#', 'g').replaceAll('A#', 'a');
const newSheet = sheet.repeat(Math.floor(TIME / sheet.length)) + sheet.substr(0, Math.floor(TIME % sheet.length));
return (newSheet.includes(m) && TIME > acc.TIME) ? { TITLE, TIME } : acc;
}, { TITLE: "(None)", TIME: 0 }).TITLE;
}
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.03.13 |
---|---|
[Programmers] Lv 2. 줄 서는 방법 (0) | 2023.03.12 |
[Programmers] (2022 KAKAO TECH INTERNSHIP) Lv 2. 두 큐 합 같게 만들기 (0) | 2023.03.09 |
[Programmers] Lv 2. 숫자 변환하기 (0) | 2023.03.09 |
[Programmers] (월간 코드 챌린지 시즌1) Lv 2. 삼각 달팽이 (0) | 2023.03.08 |
댓글