Skip to content

Commit 27baa71

Browse files
committed
Do weekly
1 parent c2576ce commit 27baa71

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

my-submissions/m1100.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution:
2+
def numKLenSubstrNoRepeats(self, s: str, k: int) -> int:
3+
letters = set()
4+
left = 0
5+
output = 0
6+
7+
for c in s :
8+
if c in letters :
9+
while s[left] != c :
10+
letters.remove(s[left])
11+
left += 1
12+
left += 1
13+
letters.add(c)
14+
15+
while len(letters) > k :
16+
letters.remove(s[left])
17+
left += 1
18+
19+
if len(letters) == k :
20+
output += 1
21+
22+
return output

0 commit comments

Comments
 (0)