Question DSA-STR-0063
HardWhat is the output of this code?
from collections import Counter
def min_window(s, t):
need, missing = Counter(t), len(t)
i = start = end = 0
for j, c in enumerate(s, 1):
if need[c] > 0:
missing -= 1
need[c] -= 1
if not missing:
while need[s[i]] < 0:
need[s[i]] += 1; i += 1
if not end or j - i < end - start:
start, end = i, j
need[s[i]] += 1; missing += 1; i += 1
return s[start:end]
print(min_window("ADOBECODEBANC", "ABC"))
- A.
ADOBEC
- B.
CODEBA
- C.
ABC
- D.
BANC
Sign up free to see the answer and a step-by-step explanation.