FastPrepLongest Substring Without Repeating Characters
Problem · String

Longest Substring Without Repeating Characters

Learn this problem
MediumAkuna Capital logoAkuna CapitalNEW GRADOA

Problem statement

Given a string s, return the length of its longest contiguous substring that contains no repeated characters.

Function

lengthOfLongestSubstring(s: String) → int

Examples

Example 1

s = "abcabcbb"return = 3

"abc" is a longest substring without repeated characters, so the answer is 3.

Example 2

s = "bbbbb"return = 1

Every substring with distinct characters contains at most one b.

Constraints

  • 1 <= s.length <= 10^5.
  • s contains English letters, digits, and common symbols.

More Akuna Capital problems

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