Uber SSE (L5A) Phone Screen
Summary
I interviewed for an Uber Senior Software Engineer (L5A) role via a phone screen where I was asked to design O(1) methods for tracking one‑time visitors in a customer visit stream.
Full Experience
Problem
You are given a stream of customer visits. Each customer is identified by an integer customerId.
A customer is called a one-time visitor if they have visited exactly once.
Implement the following methods:
postCustomerVisit(int customerId)
// Records a visit for the given customer.
getFirstOneTimeVisitor()
// Returns the first customer who has visited exactly once.
// If no such customer exists, return -1.
Example :
postCustomerVisit(2)
postCustomerVisit(5)
postCustomerVisit(2)
postCustomerVisit(3)
getFirstOneTimeVisitor() → 5
postCustomerVisit(2)
postCustomerVisit(4)
postCustomerVisit(5)
getFirstOneTimeVisitor() → 3
Constraints Up to 100,000 operations Customer IDs are positive integers
Expected Complexity :
postCustomerVisit -> O(1)
getFirstOneTimeVisitor -> O(1)
Interview Questions (1)
First One-Time Visitor in Stream
You are given a stream of customer visits. Each customer is identified by an integer customerId. A customer is called a one-time visitor if they have visited exactly once.
Implement two methods:
postCustomerVisit(int customerId): Records a visit for the given customer.getFirstOneTimeVisitor(): Returns the first customer who has visited exactly once. If no such customer exists, return -1.
Example
postCustomerVisit(2)
postCustomerVisit(5)
postCustomerVisit(2)
postCustomerVisit(3)
getFirstOneTimeVisitor() → 5
postCustomerVisit(2)
postCustomerVisit(4)
postCustomerVisit(5)
getFirstOneTimeVisitor() → 3
Constraints
- Up to 100,000 operations
- Customer IDs are positive integers
Expected Complexity
postCustomerVisit→ O(1)getFirstOneTimeVisitor→ O(1)