Longest Substring With No Duplicate Characters (Medium)
Good afternoon! Here's our prompt for today.
You may see this problem at Intercom, Pivotal, Nvidia, Canva, Segment, Carta, Figma, Weave, Amplitude, 3m, Veeva Systems, and Digitate.
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.
xxxxxxxxxx40
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
Results will appear here.