Longest Substring Without Repeating Characters
You get a string. Find the length of its longest piece of letters in a row where no letter repeats. Our example: "abcbdae" — the answer is 5, the piece "cbdae".
- input
s: a string; spaces, digits and symbols are characters too.- returns
- The length of the longest substring of
sin which no character repeats. - constraints
- 0 ≤ s.length ≤ 10000
- s: English letters, digits, symbols and spaces
- examples
- Open a test in the tests panel: it shows the input and the expected answer.
/**
* @param {string} s
* @return {number}
*/
function lengthOfLongestSubstring(s) {
}
Ctrl ↵
format
reset
saved in this browser
Stuck?
See the solution run step by step on our example, then why it works and its complexity.
Next: more sliding window problems
- 643Maximum Average Subarray IEasysolve
- 28Find the Index of the First Occurrence in a StringEasysolve
- 209Minimum Size Subarray SumMediumsolve
- 424Longest Repeating Character ReplacementMediumsolve
- 567Permutation in StringMediumsolve
- 76Minimum Window SubstringHardsolve
- 30Substring with Concatenation of All WordsHardsolve
The problem and its statement belong to LeetCode. Here are our own retelling, example and solution. Patterns Hero is not affiliated with LeetCode.