Problems > Longest Distinct Stretch > Editorial

Longest Distinct Stretch — Solution & Editorial

Back to the Problem

Remember each value's last position; when the current value reappears inside the window, jump the left edge past its previous occurrence.

Complexity: O(N)