-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
/**
* @param {string} s
* @return {number}
*/
var lengthOfLongestSubstring = function(s) {
let arr = s.split('');
let max = 0;
let temp = [];
for(let i=0,j=0;j<arr.length;){
if(arr[j] != undefined && !temp.includes(arr[j])){
temp.push(arr[j])
j++
}else{
i++
temp = arr.slice(i,j);
}
max = max > temp.length ? max : temp.length;
}
return max;
};
Metadata
Metadata
Assignees
Labels
No labels
