Muscardinus
추석 트래픽 본문
728x90
https://programmers.co.kr/learn/courses/30/lessons/17676
function solution(lines) {
const logs = lines.map((e) => e.slice(11).split(" ")).map((e) => [toTimeNumber(e[0]), Number(e[1].replace("s",""))]);
const times = logs.map((e) => [e[0] - (e[1] * 1000) + 1, e[0]]).sort((a, b) => a[0] - b[0]);
let answer = 0;
let window = [];
times.forEach(([start, end]) => {
window.push(end);
window = window.filter((e) => e > start - 1000);
answer = Math.max(window.length, answer);
});
return answer;
}
const toTimeNumber = (time) => {
const hour = (time[0]*10 + time[1]*1) * 60 * 60;
const minute = (time[3]*10 + time[4]*1) * 60;
const seconds = time[6]*10 + time[7]*1;
const millis = time[9]*100 + time[10]*10 + time[11]*1;
const amount = (hour + minute + seconds) * 1000 + millis;
return amount;
}
728x90
Comments