Startup OA Interview Question: Track Customer Visits and First-Time Visitors

19 Views
No Comments

Track Customer Visits and First-Time Visitors

Millions of customers visit our website every day. For each customer, we have a unique identifier that stays the same every time they visit. We have 2 kinds of customers: Recurrent Visitors, who have visited more than once, and One-Time Visitors, who have visited the website only once so far.

We want to implement a service that has 2 functionalities:

  • postCustomerVisit
  • getFirstOneTimeVisitor

This problem asks you to design a customer visit tracking service with two operations: recording each visit and returning the first customer who has only visited once so far. A common solution is to use a hash map to count visits and a queue or linked structure to keep candidates in visit order, removing customers once they become recurrent visitors. The key idea is to support efficient updates while preserving the earliest one-time visitor.

END
 0