Back to problems

First Customer Who Visited Only Once

Object-Oriented Programming · Uber · Medium

Requirements visit(customer_id) — log a website visit for the specified customer. A customer may generate more than one visit. firstUniqueVisitor() — produce the customer who arrived earliest among those with exactly one visit to date. Return null / a sentinel if no such customer exists. Target O(1) amortized time for each operation; in particular, firstUniqueVisitor() must not traverse the data. Notes Maintain a doubly linked list of customer IDs in arrival sequence, along…

Checking your access…