Count requests in a time window

Traverse timestamps, distinguish open and closed interval boundaries, and explain why two pointers only move forward.

Imagine a queue

For [1, 2, 3, 10], [1, 4) contains three arrivals; an arrival at 4 is excluded.

Two pointers

The data is sorted. Each pointer advances at most n times: O(n) time and O(1) extra space.

An empty array returns 0. Repeated timestamps count separately. Compare the difference < w, not ≤ w.

Original HunpeoLabs lesson; specialist review required. Reading alone does not create verified evidence.