Good evening! Here's our prompt for today.
Given a string of characters, can you find the longest substring of the string that has no repeating characters?
An example is shown below:

JAVASCRIPT
1lengthOfLongestSubstring("abracadabar");
2// 4 because it is 'brac'
Constraints
- Length of the string <=
100000
- The string will only contain lowercase letters
- Expected time complexity :
O(n)
- Expected space complexity :
O(1)
In this challenge, we'll discuss a simple but efficient method for finding the longest substring with no repeating characters.
Try to solve this here or in Interactive Mode.
How do I practice this challenge?
xxxxxxxxxx
40
var assert = require('assert');
​
var lengthOfLongestSubstring = function (s) {
// fill this in
return maximumLen;
};
​
try {
assert.equal(lengthOfLongestSubstring('algodaily'), 7);
​
console.log(
'PASSED: ' +
"`lengthOfLongestSubstring('algodaily')` should be equal to `7`"
);
} catch (err) {
console.log(err);
}
​
try {
assert.equal(lengthOfLongestSubstring('thisisatest'), 5);
​
console.log(
'PASSED: ' +
"`lengthOfLongestSubstring('thisisatest')` should be equal to `5`"
);
} catch (err) {
console.log(err);
}
​
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment
Here's our guided, illustrated walk-through.
How do I use this guide?