Quant Memo
Coding/●●●●●

Distinct prices in every window

For a price series and a window length k, report the number of distinct prices in each window of k consecutive ticks, as the window slides one tick at a time.

prices = [1, 1, 2, 3], k = 2
-> [1, 2, 2]       # windows [1,1], [1,2], [2,3]

Return the list of distinct-count values, one per window. Aim for O(n)O(n).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions