Object-Oriented Programming · Oracle · Medium
Requirements Design a tracker with these two operations: record(userId) logs one additional login for the specified user. firstUnique() returns the ID of the user who logged in earliest among all users whose lifetime login count is exactly one. If every user has logged in at least twice, return null or another agreed-upon sentinel. Assume the tracker receives relatively few login events but many calls to firstUnique(). Both operations must run in O(1) worst-case time.…
Checking your access…