File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 33class Solution :
44 def minWindow (self , s : str , t : str ) -> str :
55 char_frequency = defaultdict (lambda : 0 )
6- for c in pattern :
6+ for c in t :
77 char_frequency [c ] += 1
88 chars_matched = 0
99
1010 start = 0
1111 res = ""
1212
13- for end in range (len (string )):
14- right_char = string [end ]
15- if right_char in pattern :
13+ for end in range (len (s )):
14+ right_char = s [end ]
15+ if right_char in t :
1616 char_frequency [right_char ] -= 1
1717 if char_frequency [right_char ] == 0 :
1818 chars_matched += 1
1919
2020 while start <= end and chars_matched == len (char_frequency ):
2121 if res == "" or end - start + 1 < len (res ):
22- res = string [start :end + 1 ]
22+ res = s [start :end + 1 ]
2323
24- left_char = string [start ]
25- if left_char in pattern :
24+ left_char = s [start ]
25+ if left_char in t :
2626 if char_frequency [left_char ] == 0 :
2727 chars_matched -= 1
2828 char_frequency [left_char ] += 1
You can’t perform that action at this time.
0 commit comments