Tagged “interview”

1 post found.

Tutorials

How to study this material without drowning Data Structure & Algorithm · 2 min read Handling a DP question under pressure Data Structure & Algorithm · 3 min read Pattern recognition — reading the problem for its solution Data Structure & Algorithm · 2 min read Testing your solution before they do Data Structure & Algorithm · 2 min read A practice plan that holds Data Structure & Algorithm · 2 min read Three problems, worked end to end Data Structure & Algorithm · 3 min read
Jul 6, 2026· 2 min read ·114 views

The sliding window, four patterns deep

Turning O(n·k) into O(n) by not throwing away work you already did

Key takeaways
  • When windows overlap, do not rebuild them — update them.
  • The inner while loop is still O(n): left only ever moves forward.
  • Contiguous means window; subsequence does not.

Most array problems have an obvious brute force answer: check every window, take the best one. It works, and it is O(n·k). Consecutive windows overlap almost completely. Only one e…