LeetCode刷题(49)--Minimum Window Substring

xiaoxiao2021-02-28  6

class Solution(object): def minWindow(self, s, t): """ :type s: str :type t: str :rtype: str """ need, missing = collections.Counter(t), len(t) i = I = J = 0 for j, c in enumerate(s, 1): missing -= need[c] > 0 need[c] -= 1 if not missing: while i < j and need[s[i]] < 0: need[s[i]] += 1 i += 1 if not J or j - i <= J - I: I, J = i, j return s[I:J]
转载请注明原文地址: https://www.6miu.com/read-850233.html

最新回复(0)