Skip to content

Commit 23103ca

Browse files
committed
개행문자 추가
1 parent a1bbe09 commit 23103ca

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

longest-substring-without-repeating-characters/krokerdile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ var lengthOfLongestSubstring = function(s) {
2020
}
2121

2222
return maxLength;
23-
};
23+
};

number-of-islands/krokerdile.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
var lengthOfLongestSubstring = function(s) {
6+
let start = 0;
7+
let maxLength = 0;
8+
const seen = new Map(); // 문자 -> 마지막 인덱스
9+
10+
for (let end = 0; end < s.length; end++) {
11+
const char = s[end];
12+
13+
// 중복 문자가 이전에 등장했으면 start를 갱신
14+
if (seen.has(char) && seen.get(char) >= start) {
15+
start = seen.get(char) + 1;
16+
}
17+
18+
seen.set(char, end); // 현재 문자 위치 갱신
19+
maxLength = Math.max(maxLength, end - start + 1);
20+
}
21+
22+
return maxLength;
23+
};

reverse-linked-list/krokerdile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ function reverseList(head) {
2121
}
2222

2323
return prev; // prev는 새로운 head
24-
}
24+
}

0 commit comments

Comments
 (0)