Amazon SDE-2 | Virtual Onsite | Find the top-N question pairs
Anonymous User
943

Write a class that subscribes to a log of Alexa utterances, where each message contains line with the following fields (time,sessionId, location, questionText) - represents a question asked by customer to Alexa at time T, write algorithm to find the top-N question pairs.

For example, given the following log file containing::
2 - 1
3 - 3

10-Mar-2020 10:34:00, S1, CA, what is expiry of avocado
10-Mar-2020 10:30:00, S1, CA, how many calories in avocado
10-Mar-2020 10:32:00, S1, CA, can i eat avacado after one week

10-Mar-2020 10:31:00, S2, WY, is mango safe for dogs

10-Mar-2020 10:33:00, S2, WY, is mango safe for cats

10-Mar-2020 12:47:00, S3, MT, find best watch

10-Mar-2020 12:49:00, S3, MT, find best sports watch

11-Mar-2020 11:11:00, S5, TX, is mango safe for dogs

11-Mar-2020 11:12:00, S5, TX, is apple safe for dogs

11-Mar-2020 16:24:00, S4, CA, how many calories in guacamole

11-Mar-2020 16:23:00, S4, CA, how many calories in avocado
11-Mar-2020 16:23:00, S4, CA, what is expiry of avocado

It should return (what is expiry of avocado, how many calories in avocado)

The recruiter asked to start with top-2 question pairs rather than N. If anybody could provide a solution to this, it would be really helpful.

Comments (4)