Intern
7
```python from collections import Counter def min_s(a: str, s: str) -> str: need = set(a) window = Counter() res = "" c = 0 left = 0 best_len = float('inf') for right, char in enumerate(s): if char in need and \ window[char] += 1 if window[char]: c += 1 while c == len(need): if right - left + 1< best_len: res = s[left:right + 1] best_len = right - left + 1 if s[left] in need: window[s[left]] -= 1 if window[s[left]] == 0: c -= 1 left += 1 return res ``` The task is to implement a function `min_s(a: str, s: str) -> str` that finds the minimum substring in `s` which contains all characters from string `a`.
Компании, где спрашивали
Яндекс