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 ).
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Window String on Interview Code Editor
Sign Up
to access hints and editorial solutions for Window String
Asked In:


Click here to start solving coding interview questions