Minimum Window Substring
Updated
Problem statement
Return the shortest contiguous substring of s that contains every character of t, including the required number of repeated characters.
If several shortest windows exist, return the one with the earliest start. Compare characters exactly, including case. Return the empty string if no window exists.
Function
minWindow(s: String, t: String) → StringExamples
Example 1
s = "ADOBECODEBANC"t = "ABC"return = "BANC"The substring BANC contains all three required characters. No shorter window covers them.
Example 2
s = "a"t = "aa"return = ""The source has only one a, while the target requires two.
Example 3
s = "abdd"t = "bd"return = "bd"The characters at indices 1 and 2 form bd, which covers the target in the minimum possible length of 2.
Constraints
0 <= s.length <= 100000.1 <= t.length <= 100000.- Both strings contain printable ASCII characters, with character codes
32through126.
More Expedia Online Assessment questions
- Balanced NumbersOA · Seen Aug 2026
- REST API: Discounted PriceOA · Seen Aug 2026
- Maximum Team SizeOA · Seen Mar 2026
- Per-Domain Request LimiterOA · Seen Oct 2025
- Count Equal-Frequency SubsequencesOA · Seen Mar 2025
- Count Increasing Stock PeriodsOA · Seen Mar 2025
- Get Minimum StepsOA · Seen Oct 2024
- Rank Songs by PopularityOA · Seen Oct 2024
- Calculate the SumOA · Seen Oct 2024
- Get Maximum EfficiencyOA · Seen Oct 2024
Similar questions at other companies
- Incident MonitorStripe · OAStripe interview questions
- Longest Perfect AnagramsAmazon · OA
- Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
- Maximum Valid Substring FrequencyMicrosoft · OAMicrosoft interview questions
- Perfect SubstringAXQ Capital · OA
- Longest Distinct StringSuperhuman · OASuperhuman interview questions
- Longest Substring Without Repeating CharactersAkuna Capital · OAAkuna Capital interview questions
- Perfect SubstringsVisa · OAVisa interview questions
- Vowel SubstringSnowflake · OASnowflake interview questions
- Count Distinct Fixed-Length SubstringsAdobe · OAAdobe interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)