We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 500cee3 commit bf571ceCopy full SHA for bf571ce
1 file changed
leetcode/Study Plan/438. 找到字符串中所有字母异位词/2.py
@@ -0,0 +1,21 @@
1
+'''
2
+Author: tkzzzzzz6
3
+Date: 2026-03-12 00:57:22
4
+LastEditors: tkzzzzzz6
5
+LastEditTime: 2026-03-12 00:57:24
6
7
+class Solution:
8
+ def findAnagrams(self, s: str, p: str) -> List[int]:
9
+ cnt = Counter(p)
10
+ ans = []
11
+
12
+ left = 0
13
+ for right,c in enumerate(s):
14
+ cnt[c] -= 1
15
+ while cnt[c] < 0:
16
+ cnt[s[left]] += 1
17
+ left += 1
18
+ if right - left + 1 == len(p):
19
+ ans.append(left)
20
21
+ return ans
0 commit comments