
LinkedIn Data Scientist Interview: Real Streaming Data Question
In this article, we tackle two actual interview problems: one from LinkedIn, which focuses on streaming data and frequency analysis, and another from Meta (Facebook), which involves SQL logic for deducing social network relationships from multiple tables. We provide detailed explanations, code implementations, and relevant mathematical concepts to help you understand and solve these questions effectively.
Given an incoming stream of numbers, design an algorithm to find the k most frequent numbers at any point in the stream. This must be done "on the fly", meaning that the solution should be able to process numbers as they come in, preferably in sub-linear time and space relative to the stream size.
Let's break down the requirements: