Longest run of distinct elements

medium~25 min#hash-map#sliding-window#strings

Given a sequence, return the length of the longest contiguous run in which no element repeats.

Aim for a single pass. Be ready to say precisely when the window's left edge moves, and why it must never move backwards.

Solution — locked

Sign in to unlock this one

The solution opens once you explain the idea in your own words and it passes the grader — which needs an account to record. Signing in is free.

Log in