FastPrepMinimum Window Substring
Problems/Minimum Window Substring

Minimum Window Substring

WhatNot logoWhatNot● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A full-time applicant who went through Whatnot's interviews in early 2024 got this in the technical screen that came after a call with the recruiter. They wrote nearly the whole solution but left a small bug, so it never ran, and still moved on to the next stage.

The write-up names the classic task and gives nothing else. Here, letters only, case counts, up to 10^5 characters in each string, and the earliest start wins a tie, so each input has one answer.

Our version is about 90% the same as the reported question.

You are given two strings s and t. Find the shortest substring of s (a run of consecutive characters) that contains every character of t, including repeats: if a character appears k times in t, the substring must contain it at least k times. Upper and lower case letters are different characters.

Return that substring. If several substrings tie for the shortest length, return the one that starts earliest in s. If no substring of s works, return the empty string "".

Function

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

Examples

Example 1

s = "XQAZBYAB"t = "AB"return = "AB"

"AZB" (start 2) holds both letters, but "AB" at the end is shorter. No window shorter than 2 can hold two characters.

Example 2

s = "cabbcaab"t = "abb"return = "abb"

t needs one a and two b. The window "abb" starting at index 1 has exactly that, and no window of length 3 starts earlier with enough letters.

Example 3

s = "aBcAb"t = "ab"return = "aBcAb"

Upper and lower case are different characters. The only lowercase a is at index 0 and the only lowercase b is at index 4, so the window has to cover the whole string.

Example 4

s = "pqqp"t = "qp"return = "pq"

Both "pq" (start 0) and "qp" (start 2) have length 2 and hold one p and one q. The one that starts earlier wins.

Example 5

s = "abc"t = "cc"return = ""

t needs two copies of c, but s has only one. No window works, so the answer is the empty string.

Constraints

  • 1 <= s.length, t.length <= 105
  • s and t contain only uppercase and lowercase English letters.

More WhatNot Phone Screen questions

  • Adjacent Pair and Run RemovalPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merge Sorted Squares of Two ArraysPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey Paths from a Log StreamPHONE SCREEN · Seen Nov 2026
  • Reachable Exits in an Obstacle GridPHONE SCREEN · Seen Oct 2026
  • Palindrome with One DeletionPHONE SCREEN · Seen Oct 2026
  • Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Attraction Route Without Reusing TrailsPHONE SCREEN · Seen Sep 2026
  • Earliest Car for Each PassengerPHONE SCREEN · Seen Sep 2026
  • Minimum Stores for a Shopping ListPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Minimum Window SubstringLyft · PHONE SCREENLyft interview questions
  • Minimum Window SubstringAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Minimum Window SubstringSalesforce · PHONE SCREENSalesforce interview questions
  • Minimum Window SubstringCharacter.AI · PHONE SCREEN
  • Shortest Window Covering All LettersAdobe · PHONE SCREENAdobe interview questions
  • Minimum Window SubstringSambaNova Systems · PHONE SCREENSambaNova Systems interview questions
  • Longest Substring Without Repeating CharactersAngel One · PHONE SCREEN
  • Longest Substring Without Repeating CharactersNykaa · PHONE SCREENNykaa interview questions
  • Longest Substring Without Repeating CharactersIBM · PHONE SCREENIBM interview questions
  • Longest Substring Without Repeating CharactersTikTok · PHONE SCREENTikTok interview questions

Interview reports that mention this question

  • Whatnot interviews · March 2024

WhatNot interview experiences

  • Whatnot OA · November 2023
  • Whatnot interviews · November 2023
  • Whatnot interviews · February 2024
  • Whatnot OA · April 2024
  • Whatnot interviews · April 2024
All WhatNot interview questionsSee WhatNot hiring insights
Saved
class Solution {
    public String minWindow(String s, String t) {
        // write your code here
    }
}
Checking account…