1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| function toSecond(times) { const [hour, minute, second] = times.split(":"); return hour * 3600000 + minute * 60000 + second * 1000; }
function solution(lines) { lines = lines.map((v) => { const temp = v.split(" "); const end = toSecond(temp[1]); const start = end - temp[2].slice(0, -1) * 1000 + 1;
return [start, end]; });
lines.sort((a, b) => a[0] - b[0]);
let max = 0;
for (let a of lines) { let temp = 0; for (let b of lines) { if (b[1] >= a[0] - 999 && b[1] <= a[0]) temp++; else if (b[0] <= a[0] && b[1] > a[0]) temp++; } max = Math.max(temp, max); }
return max; }
|