Sliding-window analysis of server logs
Problem Given a stream of timestamped server-log / time-series entries, find the window (contiguous subarray) that satisfies a given constraint — for example, the longest window whose request rate stays under a threshold, or the shortest window whose total exceeds a target.
Input / Output
- Input: an array of entries (timestamp and/or value), and a constraint parameter (threshold, target sum, or distinct-count limit).
- Output: the qualifying window — its length and/or its boundary indices.
Constraints
- Up to ~1e6 entries; aim for a single pass.
- Entries arrive in non-decreasing timestamp order.
Example
- values = [2, 1, 5, 1, 3, 2], target sum ≥ 8 → shortest window = [5, 1, 3] (length 3).
asked …