Back to problems

Smallest Time-Diff Pair Per User (Orders × Ads)

Algorithm · Amazon · Medium

Requirements You receive two event collections keyed by user_id: orders[i] = (user, timestamp) and ads[j] = (user, timestamp). For each individual user, timestamps are already ordered within each collection. For each user present in both event sources, identify the order/ad timestamp pair with the smallest absolute gap, order_ts - ad_ts . The input representation is deliberately left vague; you are expected to ask the interviewer to pin down the details. Examples Notes In…

Checking your access…