← All questions
Coding
Sliding window Modifed version
Asked at
Infosys
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Ask for the exact modified constraint before committing to an algorithm.
- 02Define state that changes in O(1) when either pointer moves.
- 03Expand right and shrink left only while the defined invariant requires it.
- 04Prove each pointer is monotone and identify inputs that invalidate the approach.
Reference answer
Then expect these follow-ups
Give an example where a prefix-sum map is better.
Tests: algorithm selection
How do you prove amortized O(n)?
Tests: complexity
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question