CS小硕
Online Assesment
Optimal Utilization
Amazon Music
店面
Given tuples of (worker_id, num_hours_worked) find the top K workers ranked by number o hours worked.
Eg: Given
(1, 30), (2, 20), (1, 40), (3, 10) k = 2
Result = [1, 2]
上门
第一轮
LP Questions
Design a HashSet with Expiry time.
Methods to be implemented
boolean contains(int key)
boolean add(key)
boolean removeExpiredKeys()
Came up with simple HashMap solution first.Was asked to optimixxe for removeExpiredKeys. Then came up with a solution using both HashMap and PriorityQueue.
第二轮
Design an EventManager class and Subscriber class.
Subscriber class can subscribe to a specific event with event Id.
Rough outline of my solution
class EventManager() {
HashMap<integer, List<Subscriber> subscriber ;
subscribe(Subscriber subscriber, int eventId) {
// add this to the hashmap
}
unsubscribe(Subscriber subscriber, int eventId) {
// remove this from the hashmap
}
createEvent(int eventId) {
// create the event and call Subscriber. action() method for all its subscribers
}
}
interface Subscriber {
action() {
}
}
I had to ask a lot of clarifying questions because his question was very vague.
And he followed up with a few questions on concurrency issues etc.
第三轮
LP Questions
Given a log of (customer_id, page_visited). Find the most visited 3-page sequence.
Eg:
Given log
[1, 30]
[1, 31]
[1, 32]
[1, 33]
[2, 40]
[2, 41]
[2, 42]
[3, 30]
[3, 31]
[3, 32]
[1, 45]
[2, 43]
Answer: [30, 31, 32]
第四轮
Full on LP questions with Hiring manager - I think this is a very crucial round. I was asked a lot of LP questions with a lot of follow up questions.
All the interviews were on Whiteboard.