Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

s =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Maintain a sliding window with no duplicate characters.

Approach

Track the last index where each character was seen. Move the left boundary l forward when a duplicate appears inside the window.

Why it works

The window [l..r] is always kept duplicate-free; each index advances monotonically, giving linear time.

Code
Loading...
Complexity
Time: O(n)
Space: O(min(n, alphabet))
Solution
Updated: 2026-02-23

Idea

Maintain a sliding window with no duplicate characters.

Approach

Track the last index where each character was seen. Move the left boundary l forward when a duplicate appears inside the window.

Why it works

The window [l..r] is always kept duplicate-free; each index advances monotonically, giving linear time.

Code
Loading...
Complexity
Time: O(n)
Space: O(min(n, alphabet))