CodingMedium
Longest Substring Without Repeating Characters
Given a string s, return the length of the longest substring in which no character appears more than once.
A substring is a run of characters that sit next to each other in s. Characters picked from different places don’t count.
Example 1
Input
s = "banana"Output3“ban” has no repeated character, and every longer substring does.
Example 2
Input
s = "aaaa"Output1Example 3
Input
s = "dvdf"Output3The answer is “vdf”. When the second d arrives, the run can keep the v rather than start over.
Constraints
- 0 ≤ s.length ≤ 5 · 10⁴
- s holds English letters, digits, symbols and spaces