This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Given a string "input", find the length of the longest substring without repeating characters. | |
const lengthOfLongestSubstring = (input = "") => { | |
const chars = input.split(""); | |
let buffer = new Map(); // stores the last index for each encountered character | |
let maxLen = 0; | |
for (let index = 0; index < chars.length; index++) { | |
const char = chars[index]; | |
if (!buffer.has(char)) { |