2dbi
Home/Google/Minimum Window Substring
GGoogle·DSAL4Phone Screen – Coding

Minimum Window Substring

Problem

Given strings s and t, return the minimum window substring of s that contains all characters of t. Return "" if no such window exists.

Example

s = "ADOBECODEBANC", t = "ABC"
Output: "BANC"

Constraints

  • 1 ≤ s.length, t.length ≤ 10^5
  • s and t consist of uppercase and lowercase English letters

Expected

O(n) time solution using the sliding window technique. Google interviewers often follow up by asking you to return all minimum windows if multiple exist.

added 6 days ago
LeadersAccount