function solution(lines) {
var answer = 0;
const getStartEndMilliSeconds = (str) => {
const [yms, endTime, duration] = str.split(' ')
const date = new Date(`${yms} ${endTime}`)
const endMilliSeconds = date.getTime();
const startMilliSeconds = endMilliSeconds - duration.slice(0, -1)* 1000 + 1;
return [startMilliSeconds , endMilliSeconds ]
}
const timeStamp = []
lines.map(line => {
const [start, end] = getStartEndMilliSeconds(line)
timeStamp.push([start - 1000, 'start'])
timeStamp.push([end])
})
let count =0;
let max =-Infinity;
timeStamp.sort((a,b) => a[0] - b[0]).forEach(([time, isStart]) => {
count += isStart ? 1 : -1;
max = Math.max(count, max);
})
return max;
}
Level
프로그래머스 Lv3
Day
11일
kakao
2018 카카오 블라인드