flipkart logo
Flipkart· SDE I

Flipkart Interview Question

Result
No Offer
Posted
30 May 2021
315 reads

Summary

I recently interviewed at Flipkart for an SDE1 role and was challenged to design a data structure for tracking the top K stocks from a real-time stream. Unfortunately, I was unable to provide a satisfactory solution.

How it went

I recently had an interview at Flipkart for an SDE1 position. During the technical round, I was presented with a design problem: to create a data structure capable of efficiently providing the top 10 stocks from a continuous stream of (id, stock-price) tuples at any given point in time. The interviewer explained that a function like getTop10() should return a list of the 10 stocks with the maximum current value. An example was provided: for a stream such as (a, 10), (b,20), (c,30), (d, 40), (a, 30), (d,10), a call to getTop2() should yield [{a,30}, (c,30)]. I attempted to implement a solution using a maxHeap, but the interviewer did not seem satisfied with my approach, and I felt I couldn't deliver a complete or optimal answer.

Questions asked (1)

  1. 01

    Design Data Structure for Top K Stocks in Stream

    Data Structures & Algorithms

    Design a data structure to give top 10 stocks from a stream of tuple at any point of time.
    The tuple format is (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)];

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Flipkart recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!