Maximum Population Year LeetCode solution in JavaScript

1
var maximumPopulation = function (logs) {
2
const count = new Array(101).fill(0);
3

4
for (const [birth, death] of logs) {
5
count[birth - 1950]++;
6
count[death - 1950]--;
7
}
8

9
let max = 0;
10

11
for (let i = 1; i < 101; i++) {
12
count[i] += count[i - 1];
13

14
if (count[i] > count[max]) max = i;
15
}
16

17
return 1950 + max;
18
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0