Loading...
Loading...
Loading...
Given a text s and required letters t (letters may repeat), find the shortest part of s that contains every letter of t with at least the same counts. If there are several, print the leftmost. If none exists, print NONE.
Example 1
Input
adobecodebanc abc
Output
banc
banc is the shortest.
Example 2
Input
a b
Output
NONE
Try the problem first. Open one hint at a time.
Count how many of each required letter are still missing.
Grow the right end until nothing is missing, then shrink the left end as far as possible and record the window.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor