Company: Cisco_11july
Difficulty: medium
Online Auction Sniper Detector Problem Description An online auction site is investigating "sniping": short bursts of last-second bids that try to outpace honest bidders. The fraud team looks at time windows of length W seconds. For the bid placed at time T , the window is the closed interval [T - W, T] : a bid placed at time T - W is still inside it. A user is sniping at that moment if that user placed at least K bids inside the window. Bids arrive in chronological order. Bid i is placed at time t[i] by the user with id u[i] . When bid i arrives, only bids 0..i exist, and the window is [t[i] - W, t[i]] . For each bid, answer two questions: flag : is the current bid part of a suspicious window? It is 1 if user u[i] has at least K bids in the window, counting bid i itself, and 0 otherwise. smallest_sniper : the smallest user id that is sniping in the same window, or -1 if no user is. This user does not have to be the one who placed bid i . Complete the function solve(N, W, K, t, u) , wh