Python data engineering interview problem. Difficulty: advanced. Pattern: Sliding Window. About 20 minutes. Part of the Pro drill bank.
An analytics job counts distinct visitors inside each sliding window of events so a spike of one user does not look like a crowd.
Return the distinct-visitor count for each window of a given size.
Input: distinct_in_windows([(1, 'a'), (2, 'b'), (8, 'a')], 5) Output: [1, 2, 1] This input follows the stated rules and produces this output.
Topics: lakebench, python, sliding-window.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: For a stream of timestamped visitor ids, report the count of distinct visitors in every trailing 60-second window.
Return the distinct-visitor count for each window of a given size.