Hardware interview practice
Find the longest unique token run
For each bounded protocol-token frame, report the longest contiguous run containing no repeated token ID, including its inclusive start and end indices.
Reviewed example
Work through one case
Input
accepted token frame = [1, 2, 1, 3, 4, 3]Expected output
best_start=1; best_end=4; best_length=4; run=[2, 1, 3, 4]The repeated 1 advances the window start to index 1, and the later repeated 3 closes the longest unique run.
What to cover
Requirements
- Support token IDs 0 to 15 and frame lengths from 1 to 64.
- Track only accepted tokens; bubbles and downstream backpressure must not change indices.
- Never move the current window start backward when a repeated token lies before the active window.
- On equal maximum lengths, keep the run with the earliest start index.
- Clear or invalidate last-seen state between frames and hold the final result stable.
