Mask secret occurrences

Write codeMedium25 min

Your task

A scrubber hides a leaked secret before an incident report is shared. It works one character at a time: masking a character replaces it with a symbol nobody can read, which breaks every occurrence of the secret that covers that position. The report is safe once no occurrence survives anywhere in it, and occurrences may overlap, so a single mask can break several at once. Reviewers hate a page full of holes, so the scrubber masks as few characters as it possibly can. Given report and secret, return the smallest number of characters that have to be masked. Return 0 when secret is empty, when it is longer than report, or when it never appears.

Examples

secret_mask_budget(report: str, secret: str) -> int
Example 1
Inputsecret_mask_budget("aaaa", "aa")
Output2
Example 2
Inputsecret_mask_budget("abcabcabc", "abc")
Output3
Example 3
Inputsecret_mask_budget("banana", "an")
Output2