Back to problems

Earliest Single-Visit ID

Object-Oriented Programming · Uber · Medium

Build a data structure that consumes a sequence of post(id) events and, on request, reports the oldest ID that has so far been posted only one time. The structure must support two operations: post(id): register a single visit for id. getEarliestSingleVisit(): among all IDs whose post count is currently exactly one, return the one whose first appearance came before the others. If no ID has a count of exactly one, return -1. In the test-case format, the first line gives the…

Loading the rest of the question…