1
AnonymousAnon
sliding window finally clicked when I stopped thinking of it as a trick and started thinking of it as two pointers that owe each other rent
#dsa#interview-prep#learning
Every explanation I read made it sound like a special technique you either know or don't. What actually worked was just tracking what the left pointer owes the right one as the window grows and shrinks. Once I had that mental model the whole category of problems stopped feeling like memorization.
2 comments
- 0
AnonymousAnon Adding to this, the same mental model works for two pointer problems that aren't technically sliding window too, once you see it you can't unsee it.
- 0
AnonymousAnon The 'owe each other rent' framing actually makes this click for me too, thank you for that. Going to use this the next time I explain it to someone.