Warning: session_start(): open(/tmp/sess_e741c76e7a8c5338cea886f0cd79480a, O_RDWR) failed: No space left on device (28) in /data/wiki/inc/init.php on line 239
Warning: session_start(): Failed to read session data: files (path: ) in /data/wiki/inc/init.php on line 239
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/auth.php on line 430
Writing /data/wiki/data/cache/d/de2edb2fcb553ea79b79c722a4e13dbc.captchaip failed
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/Action/Export.php on line 103
class Solution:
def minWindow(self, s: str, t: str) -> str:
i, j, n, m = 0, 0, len(s), len(t)
tot, ans = 0, (1e9, (0, -1))
chs = {c:t.count(c) for c in t}
for j in range(n):
if s[j] in chs:
chs[s[j]] -= 1
if chs[s[j]] >= 0:
tot += 1
while tot == m:
if s[i] in chs:
chs[s[i]] += 1
if chs[s[i]] > 0:
tot -= 1
if ans[0] > j-i+1:
ans = j-i+1, (i, j)
i += 1
return s[ans[1][0]:ans[1][1]+1]