A sliding window is an abstract concept commonly used in array/string problems. A window is a range of elements in the array/string which usually defined by the start and end indices, i.e. [i, j)[i,j) (left-closed, right-open). A sliding window is a window “slides” its two boundaries to the certain direction. For example, if we slide [i, j)[i,j) to the right by 11 element, then it becomes [i+1, j+1)[i+1,j+1) (left-closed, right-open).
String: abcdefggadvopesgacbesmqrs Current: s[i]=a Current s[j]=a Not Contain Character a Current: s[i]=a Current s[j]=b Not Contain Character ab Current: s[i]=a Current s[j]=c Not Contain Character abc Current: s[i]=a Current s[j]=d Not Contain Character abcd Current: s[i]=a Current s[j]=e Not Contain Character abcde Current: s[i]=a Current s[j]=f Not Contain Character abcdef Current: s[i]=a Current s[j]=g Not Contain Character abcdefg Current: s[i]=a Current s[j]=g bcdefg Current: s[i]=b Current s[j]=g cdefg Current: s[i]=c Current s[j]=g defg Current: s[i]=d Current s[j]=g efg Current: s[i]=e Current s[j]=g fg Current: s[i]=f Current s[j]=g g Current: s[i]=g Current s[j]=g Current: s[i]=g Current s[j]=g Not Contain Character g Current: s[i]=g Current s[j]=a Not Contain Character ag Current: s[i]=g Current s[j]=d Not Contain Character adg Current: s[i]=g Current s[j]=v Not Contain Character adgv Current: s[i]=g Current s[j]=o Not Contain Character adgov Current: s[i]=g Current s[j]=p Not Contain Character adgopv Current: s[i]=g Current s[j]=e Not Contain Character adegopv Current: s[i]=g Current s[j]=s Not Contain Character adegopsv Current: s[i]=g Current s[j]=g adeopsv Current: s[i]=a Current s[j]=g Not Contain Character adegopsv Current: s[i]=a Current s[j]=a degopsv Current: s[i]=d Current s[j]=a Not Contain Character adegopsv Current: s[i]=d Current s[j]=c Not Contain Character acdegopsv Current: s[i]=d Current s[j]=b Not Contain Character abcdegopsv Current: s[i]=d Current s[j]=e abcegopsv Current: s[i]=v Current s[j]=e abcegops Current: s[i]=o Current s[j]=e abcegps Current: s[i]=p Current s[j]=e abcegs Current: s[i]=e Current s[j]=e abcgs Current: s[i]=s Current s[j]=e Not Contain Character abcegs Current: s[i]=s Current s[j]=s abceg Current: s[i]=g Current s[j]=s Not Contain Character abcegs Current: s[i]=g Current s[j]=m Not Contain Character abcegms Current: s[i]=g Current s[j]=q Not Contain Character abcegmqs Current: s[i]=g Current s[j]=r Not Contain Character abcegmqrs Current: s[i]=g Current s[j]=s abcemqrs Current: s[i]=a Current s[j]=s bcemqrs Current: s[i]=c Current s[j]=s bemqrs Current: s[i]=b Current s[j]=s emqrs Current: s[i]=e Current s[j]=s mqrs Current: s[i]=s Current s[j]=s mqr Current: s[i]=m Current s[j]=s Not Contain Character mqrs