Quant Memo
Coding/●●●●●

Longest run of trades with no repeated symbol

You have the sequence of symbols printed on a venue, one per tick. Find the length of the longest contiguous stretch in which no symbol repeats (every symbol inside the window is distinct).

symbols = ["A", "B", "C", "A", "D", "B"]
-> 4            # the stretch C A D B is all distinct

Return the maximum window length. Aim for O(n)O(n).

Show a hint

When the incoming symbol was already seen inside the current window, where must the left edge jump to?

Your answer

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

More Coding questions