Company: Cisco
Difficulty: medium
Ride-Share Surge Pricing Replay Problem Description A ride-share company is replaying a stream of pricing logs to detect anomalies. Each log entry is a ride request with a timestamp (in seconds since a fixed reference epoch) and a fare (f in cents). The pricing fairness team has a question to answer: for each ride in the log, was the fare charged in the past 5 minutes (300 seconds) too high? Concretely, ride i is flagged as surge-anomalous if its fare f_i is strictly greater than the 90th percentile of fares in the window ending at the current ride's timestamp, 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 means rides are also processed in order of their timestamp. The 90th percentile fare is computed using the "nearest-rank" convention with n rides in the window: fares in ascending order. The current ride itself counts toward the window (so n ≥ 1). The