Flipkart Interview Question
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-05-30Added By Anonymous
Source: Link
Company: Flipkart
Role: SDE1
Stage: unknown
Location: unknown
Year: unknown
I got this question at a recent flipkart interview for SDE1. Design a data structure to give top 10 stocks from a stream of tuple at any point of time. tuple (id, stock-price) Basically, getTop10() should be returning a list of top 10 stocks having maximum value at any point of time. For example, Stream -->>(a, 10), (b,20), (c,30) (d, 40) (a, 30) (d,10) getTop2() returns [{a,30}, (c,30)]; I was not able to give a satisfactory solution. I tried using maxHeap but interviewer did not seem satisfied,
Role: SDE1
Stage: unknown
Location: unknown
Year: unknown
I got this question at a recent flipkart interview for SDE1. Design a data structure to give top 10 stocks from a stream of tuple at any point of time. tuple (id, stock-price) Basically, getTop10() should be returning a list of top 10 stocks having maximum value at any point of time. For example, Stream -->>(a, 10), (b,20), (c,30) (d, 40) (a, 30) (d,10) getTop2() returns [{a,30}, (c,30)]; I was not able to give a satisfactory solution. I tried using maxHeap but interviewer did not seem satisfied,