Company: Cisco
Difficulty: medium
A ride-share company is replaying a stream of pricing logs to detect anomalies. Each log entry is a ride request with a timestamp t_i (in seconds since a fixed reference epoch) and a fare f_i (in cents). The pricing fairness team has a specific rule for how a ride was priced within the past 5 minutes (300 seconds). Consider ride i is "flagged as surge-anomalous" if its fare f_i is strictly greater than the 90th percentile of fares in its window with every earlier ride whose timestamp lies in (t_i - 300, t_i] (a half-open window looking back 300 seconds). Rides are replayed in the order given, in chronological order which is the same as sorted order of timestamp. The 90th percentile is computed using the "nearest-rank" convention with n rides in the window: fares are sorted in ascending order and the 90th-percentile fare is the fare at the [0.9 · n]-th position (1-indexed, using ceiling/nearest-rank convention) . The current ride itself counts toward the window (so n ≥ 1). Since the cur