We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a2976d0 commit b819cddCopy full SHA for b819cdd
longest-substring-without-repeating-characters/hyunjung-choi.kt
@@ -0,0 +1,24 @@
1
+/**
2
+ * 시간복잡도: O(n)
3
+ * 공간복잡도: O(min(m,n)) - m은 문자셋 크기
4
+ */
5
+
6
+class Solution {
7
+ fun lengthOfLongestSubstring(s: String): Int {
8
+ val seen = mutableSetOf<Char>()
9
+ var left = 0
10
+ var maxLength = 0
11
12
+ for (right in s.indices) {
13
+ while (s[right] in seen) {
14
+ seen.remove(s[left])
15
+ left++
16
+ }
17
18
+ seen.add(s[right])
19
+ maxLength = maxOf(maxLength, right - left + 1)
20
21
22
+ return maxLength
23
24
+}
0 commit comments