Longest Substring Without Repeating Characters

medium · string, sliding-window, hash-map

Longest Substring Without Repeating Characters

Given a string s, return the length of the longest substring without repeating characters.

Function signature

func LengthOfLongestSubstring(s string) int

Example

s = "abcabcbb"
output = 3

Constraints

  • 0 <= len(s) <= 200_000
  • s consists of ASCII characters

Notes

  • Use a sliding window with a map of last‑seen indices.
Run tests to see results
No issues detected