Window String

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in linear time complexity.
Note that when the count of a character C in T is N, then the count of C in minimum window in S should be at least N.

Example :

T = "ABC"

Minimum window is "BANC"


  • If there is no such window in S that covers all characters in T, return the empty string ''.
  • If there are multiple such windows, return the first occurring minimum window ( with minimum start index ).
Interview Code Editor
  • Solution Approach
  • Complete Solution
2801 successful submissions.
Asked In:
  • Google
  • Directi
Click here to jump start your coding interview preparation