Quant Memo
Coding/●●●●●

Longest window where no symbol repeats thrice

Given the tape as a sequence of symbols, find the length of the longest contiguous stretch in which no symbol appears more than twice.

symbols = ["A", "B", "A", "A", "B"]
-> 4            # the stretch B A A B: A twice, B twice

Return the maximum window length in which every symbol's count is at most two. 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