Longest Distinct String
Problem statement
Given a string s, return the length of its longest contiguous substring in which no character appears more than once.
A substring is a contiguous sequence of characters within s. Return only the maximum length, not the substring itself.
Function
longestDistinctString(s: String) → intExamples
Example 1
s = "abcc"return = 3The substring "abc" contains no repeated character and has length 3.
Example 2
s = "abcabcbb"return = 3Substrings such as "abc" have length 3, and every longer substring repeats a character.
Example 3
s = "bbbbb"return = 1Every distinct-character substring contains only one b.
Constraints
1 <= s.length <= 100000scontains printable ASCII characters.
Source note: The source slide shows the objective, uniqueness rules, and the worked abcc example.