Intern
30
```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 ``` La tâche consiste à implémenter une fonction `min_s(a: str, s: str) -> str` qui trouve la sous-chaîne minimale dans `s` contenant tous les caractères de la chaîne `a`.
Entreprises à qui on a demandé
Яндекс