PythiloHard · 40 min · Task 88 of 100 · progress kept in this browser

Minimum covering substring

Return the shortest substring of text containing every character of pattern with its multiplicity. Choose the earliest on a tie. Empty pattern or no cover returns an empty string.

from collections import Counter
needed = Counter('AAB')
needed['A'] -= 1
print(needed['A'])  # one A still missing
Your task

Return the shortest substring of text containing every character of pattern with its multiplicity. Choose the earliest on a tie. Empty pattern or no cover returns an empty string.