Implement min_window_with_counts(s, t)
Task
Write a function:
-
min_window_with_counts(s: str, t: str) -> tuple[int, int]
that returns the inclusive (start_index, end_index) of the shortest substring of s containing all characters in t with at least their required multiplicities.
Rules and Constraints
-
ASCII strings; case-sensitive; indices are 0-based.
-
Return (-1, -1) if no such window exists.
-
The window is contiguous (cannot skip characters); whitespace and punctuation count as normal characters.
-
If multiple windows have the same minimal length, return the one with the smallest start index; if still tied, the one with the smallest end index.
-
Time complexity must be O(n) and space O(Σ) using a sliding window and frequency maps; do not sort or use nested scans over s.
-
Must handle large inputs (len(s) up to 2e6) without quadratic behavior.
-
Assume t is non-empty; if t is empty, treat as no window and return (-1, -1).
Deliverables
-
The function implementation using a linear-time sliding window with frequency maps and a satisfied counter.
-
At least 3 test cases including the ones below.
Required Test Cases
-
s = "ADOBECODEBANC", t = "ABC" → expected (9, 12) for substring "BANC".
-
s = "aAaBbBc", t = "Aab" → the minimal valid window is (1, 4) for substring "AaBb". Note: the prompt’s illustrative substring "aAaB" at (0, 3) does not contain the required lowercase 'b', so it is not valid under case-sensitive matching.
-
s = "xyzzzy", t = "zz" → expected (2, 3) for substring "zz". Explain how counts and the satisfied counter are maintained.