window anatomyA window is a contiguous rangeName the left edge of a windowName the right edge of a windowWindow length is right minus left plus oneEmpty window versus one-cell windowWindow over an empty sequence
expandGrow the window by moving rightInclude the new rightmost cellUpdate window state on includeExpand until a constraint is metExpand across the whole arrayExpand is the only way the right edge moves
shrinkShrink the window by moving leftExclude the old leftmost cellUpdate window state on excludeShrink while the window is invalidShrink to the smallest valid windowLeft never passes right in a window
fixed-length windowsFix the window length in advanceSeed the first k cellsSlide by dropping left and adding rightFixed length pairs include with excludeThe last window ends at the last index
variable-length windowsLength is discovered not givenExpand first then shrinkThe valid window is a candidateTrack the best valid lengthTrack the best valid boundsRestart is not the same as shrink
window aggregatesMaintain the sum of the windowMaintain counts inside the windowMaintain distinct count in the windowMaintain min or max of the windowRecompute versus incremental window updateInvalid window still has a defined state
constraint windowsAt most k distinct in the windowAt most k replacements in the windowAt most k zeros in the windowCover every required characterAll unique characters in the windowWindow product stays under a limit
longest vs shortestLongest valid window expands greedilyShortest valid window shrinks greedilyRecord the answer when the window is validDo not record an invalid windowEqual-length ties pick first or last
string windowsWindow on characters not wordsAnagram window has a fixed lengthCovering window has a requirement mapUnique-character window shrinks on a repeatAlphabet size bounds the window counts
window tracesDraw left and right after each window movePrint the window contents at a candidateProve a discarded prefix cannot returnCount how many times each index is a window edge
complexity for sliding windowsEach index enters the window onceEach index leaves the window onceRecognize an amortized linear window scanExtra space of the window stateDeque extrema are still one pass
problem decomposition for windowsTranslate contiguous into a windowDecide fixed versus variable window lengthDecide longest versus shortest windowDecide window versus prefix sumsDecide window versus two pointers