Problem · String

Longest Substring Without Repeating Characters

Learn this problem
MediumAtlassian logoAtlassianFULLTIMEOA

Problem statement

Return the length of the longest contiguous substring of s whose characters are all distinct.

Function

lengthOfLongestSubstring(s: String) → int

Examples

Example 1

s = "abcabcbb"return = 3

"abc" is a longest substring with no repeated character.

Constraints

  • 0 <= s.length <= 200000
  • s contains printable ASCII characters.

More Atlassian problems

drafts saved locally
public int lengthOfLongestSubstring(String s) {
  // Write your code here.
}
s"abcabcbb"
expected3
checking account