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 f83b231 commit 4973894Copy full SHA for 4973894
minimum-window-substring/printjin-gmailcom.py
@@ -0,0 +1,23 @@
1
+from collections import Counter
2
+
3
+class Solution:
4
+ def minWindow(self, s, t):
5
+ need = Counter(t)
6
+ missing = len(t)
7
+ left = start = end = 0
8
+ window = {}
9
+ for right, char in enumerate(s, 1):
10
+ if need[char] > 0:
11
+ missing -= 1
12
+ need[char] -= 1
13
+ if missing == 0:
14
+ while left < right and need[s[left]] < 0:
15
+ need[s[left]] += 1
16
+ left += 1
17
+ if end == 0 or right - left < end - start:
18
+ start, end = left, right
19
20
+ missing += 1
21
22
+ return s[start:end]
23
0 commit comments