The Uber phone screen asked me to design a data structure that tracks repeated ID visits and can return the earliest ID that has appeared exactly once so far.
The problem was closely related to LeetCode 1429 — First Unique Number. The main follow-up was to improve the query operation to constant or amortized constant time while handling IDs that later become duplicates.
Interview Details
Coding — Earliest ID Seen Exactly Once
Design a data structure supporting two operations:
post(id)
getEarliestSingleVisit()
post(id)
getEarliestSingleVisit()
post(id) records another occurrence of the given ID.
getEarliestSingleVisit() returns the earliest ID, by first appearance order, that has been posted
Unlock Full Details
Create a free account to unlock this interview experience report.