Back to problems

Deduplicate Events List (with Sorting + Map/Stack)

Algorithm · Amazon · Easy

Remove Duplicate Events You receive an event collection named events. Every event includes: event_id: an integer, which may be zero or negative timestamp: an integer value Events are not necessarily ordered, and one event_id can occur more than once. Deduplication requirement: For each event_id, retain the single event having the greatest (most recent) timestamp; remove every other occurrence. Return the remaining events ordered by (event_id ascending, timestamp ascending).…

Checking your access…