Warning: session_start(): open(/tmp/sess_10cbbcbf9926a5f77ead804de2d42099, 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

Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/actions.php on line 38

Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/lib/tpl/dokuwiki/main.php on line 12
2020-2021:teams:tle233:code3 [CVBB ACM Team]

用户工具

站点工具


2020-2021:teams:tle233:code3
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]
2020-2021/teams/tle233/code3.txt · 最后更改: 2020/05/10 15:02 由 marvolo