Write a function. Test real cases. Improve your solution.
Given unsorted nonnegative integer event timestamps and a positive integer windowMs, find the busiest fixed-length time window. Candidate windows start at an event timestamp and include timestamps t where start <= t < start + windowMs; the right endpoint is excluded. Duplicate timestamps represent separate events and all count. Return {start, end, count}, choosing the earliest start if counts tie. Return null for no events. Timestamps and their window endpoints are safe JavaScript integers. Leave the input unchanged. Aim to avoid counting every candidate window from scratch.
[
[
100,
10,
11,
12,
40
],
5
]{
"start": 10,
"end": 15,
"count": 3
}[
[
0,
10,
19
],
10
]{
"start": 10,
"end": 20,
"count": 2
}[
[
5,
5,
5,
6,
9
],
2
]{
"start": 5,
"end": 7,
"count": 4
}[
[
30,
31,
10,
11
],
2
]{
"start": 10,
"end": 12,
"count": 2
}[ [], 100 ]
null
[
[
42
],
5
]{
"start": 42,
"end": 47,
"count": 1
}[
[
2,
0,
0,
1,
1,
1
],
1
]{
"start": 1,
"end": 2,
"count": 3
}[
[
8,
3,
6
],
20
]{
"start": 3,
"end": 23,
"count": 3
}Your code runs in your browser. These exercises use synchronous JavaScript functions and built-in data types; DOM access, network requests, and npm imports are unavailable. Runs stop after about four seconds. Test results support self-study and don’t certify proficiency.