FastPrepLongest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Goldman Sachs logoGoldman Sachs● MediumFULLTIMEINTERNPHONE SCREENONSITE INTERVIEW
Learn

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 Goldman Sachs problems

See Goldman Sachs hiring insights
public int lengthOfLongestSubstring(String s) {
  // Write your code here.
}
s"abcabcbb"
expected3
Checking account…