Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 350 Bytes

sliding-window.md

File metadata and controls

18 lines (12 loc) · 350 Bytes
let list = [];

let start = 0;
let end = 0;

for (end = 0; end < list.length; end++) {

  list[end]; // Do something with the right element just added to the window
    
  while (/* condition to move the start pointer */) {
    list[start]; // Do something with the left element that will be removed from the window
    start += 1;
  }
}