Back to problems

Implement sliding-window device anomaly

Algorithm · PayPal · Hard

Design a fraud-detection signal for a payments platform. Implement process_logins(events) (named solution in the Python harness), which consumes a stream of login records ordered by time and produces an alert whenever one account collects successful logins from 4 or more different devices within some 600-second sliding window. Every record is a 4-tuple (user_id, ts, device_id, success). Here user_id is the account, ts is an integer timestamp measured in seconds, device_id…

Checking your access…