Skip to content

Commit e40e09a

Browse files
committed
[LEET] 3. Longest Substring Without Repeating Characters (medium)
1 parent 5c50555 commit e40e09a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

허현빈/4주차/260119-1.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
var lengthOfLongestSubstring = function(s) {
6+
let max = 0;
7+
for(let i = 0 ; i < s.length; i++){
8+
let count = 0;
9+
const set = new Set()
10+
for(let j = i; j < s.length; j++){
11+
if(set.has(s[j])){
12+
break;
13+
}else{
14+
set.add(s[j])
15+
count++
16+
}
17+
}
18+
if(count > max) {max = count}
19+
}
20+
return max
21+
};

0 commit comments

Comments
 (0)