forked from onlybooks/python-algorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path76-1.py
25 lines (20 loc) · 705 Bytes
/
76-1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import collections
from typing import List
class Solution:
def minWindow(self, s: str, t: str) -> str:
def contains(s_substr_lst: List, t_lst: List):
for t_elem in t_lst:
if t_elem in s_substr_lst:
s_substr_lst.remove(t_elem)
else:
return False
return True
if not s or not t:
return ''
window_size = len(t)
for size in range(window_size, len(s) + 1):
for left in range(len(s) - size + 1):
s_substr = s[left:left + size]
if contains(list(s_substr), list(t)):
return s_substr
return ''