FastPrepMinimum Window Substring
Problems/Minimum Window Substring

Minimum Window Substring

LinkedIn logoLinkedIn● HardFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names the minimum-length-substring exercise but does not preserve its full statement. The judged contract uses the conventional minimum covering window with multiplicities and earliest-start tie handling. It matches the report at about 88%.

Given strings s and t, return the shortest contiguous substring of s that contains every character of t, including repeated characters with their required multiplicities.

If no such substring exists, return the empty string. If several valid windows have the same minimum length, return the one that starts earliest in s.

Function

minWindow(s: String, t: String) → String

Examples

Example 1

s = "ADOBECODEBANC"t = "ABC"return = "BANC"

BANC is the shortest window containing A, B, and C.

Example 2

s = "a"t = "aa"return = ""

The source string does not contain two copies of a.

Example 3

s = "abdcab"t = "ab"return = "ab"

Two length-two windows qualify, so the earlier one is returned.

Constraints

  • 1 <= s.length, t.length <= 10^5.
  • s and t contain ASCII letters and digits.

More LinkedIn problems

  • Explore an Unknown Grid and Find a PathONSITE INTERVIEW · Seen Nov 2026
  • Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public String minWindow(String s, String t) {
        // Write your solution here.
    }
}
Checking account…