Minimum Window Substring
Updated
Problem statement
Given strings s and t, return the shortest contiguous substring of s that contains every character of t, including duplicate occurrences.
If no such substring exists, return the empty string. The answer is guaranteed to be unique whenever it exists.
Function
minWindow(s: String, t: String) → StringExamples
Example 1
s = "ADOBECODEBANC"t = "ABC"return = "BANC""BANC" contains A, B, and C, and no shorter substring contains all three.
Example 2
s = "a"t = "a"return = "a"The entire source string is the only window and contains the required character.
Example 3
s = "a"t = "aa"return = ""The source string has only one a, so it cannot satisfy the target multiplicity.
Constraints
1 <= s.length, t.length <= 2 * 10^5.sandtcontain printable ASCII characters.- If a valid minimum window exists, it is unique.
More Goldman Sachs Onsite Interview questions
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
- First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Dungeon HealthONSITE INTERVIEW · Seen Sep 2026
- Insert, Delete, And Get Random In Constant TimeONSITE INTERVIEW · Seen Sep 2026
- Least Recently Used CacheONSITE INTERVIEW · Seen Sep 2026
- Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Minimum Window SubstringAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Minimum Window SubstringLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Minimum Covering SubstringByteDance · ONSITE INTERVIEWByteDance interview questions
- Minimum Window SubstringMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Minimum Window SubstringHighspot · ONSITE INTERVIEW
- Longest Substring with At Most K Distinct CharactersAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Longest Substring Without Repeating CharactersOracle · ONSITE INTERVIEWOracle interview questions
- Longest Substring Without Repeating CharactersSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Longest Substring Without Repeating CharactersGoogle · ONSITE INTERVIEWGoogle interview questions
- Longest Substring Without Repeating CharactersInfosys · ONSITE INTERVIEWInfosys interview questions