Uber Interview Question

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2022-10-08Added By Anonymous
Source: Link

Company: Uber

Role: software engineer ii, senior software engineer

Interview Stage: Onsite


Original Post Content:


Design a RATE-LIMITER. There is a vector of pair (customerId, time(in milliseconds) in which he ping),we have to return a vector of bool values as answer if the given pair is valid or not . A unique user can ping at most twice in a 1-second duration.

My Approach

Take a map of pair(customer id, time in seconds). For any pair check, if the map count>2 then push false in the ans list/vector else push true. Is this approach is correct? If not please suggest the correct one.

Comments