Shortest window covering at least k distinct symbols
You have the sequence of symbols traded on a venue, one per tick. Find the length of the shortest contiguous stretch that contains at least k distinct symbols. If no such stretch exists, return .
symbols = ["A", "B", "A", "C", "B"], k = 3
-> 3 # the stretch A C B (or B A C) hits 3 distinct
Return the minimum window length. Aim for .
Show a hint
Grow the window until it is valid, then shrink from the left as far as you can while it stays valid, recording the length each time.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.