Company: Cisco

Difficulty: medium

Problem Statement

An online auction site is investigating "sniping" — last-second bidding bursts intended to outpace honest bidders. The fraud team defines a suspicious window as any contiguous time window of length W seconds in which at least K bids were placed by the same user. Bids arrive in chronological order. For each bid, the fraud team wants two answers: Is the current bid part of a suspicious window? i.e., does the current user have at least K bids (including this one) within the last W seconds? What is the smallest user id that is currently sniping? i.e., has at least K bids in the latest W-second window ending at the current bid's timestamp. Output -1 if no user qualifies. Input Format N W K t1 u1 t2 u2 ... tN uN N — number of bids W — window length (seconds) K — sniping threshold (bids per user) bids[i] = (t i , u i ) t i = timestamp u i = user id Timestamps are strictly increasing. Output Format Print one line per bid: flag smallest_sniper flag = 1 if the current bid's user has at least K b

More Cisco OA questionsInterview experiences