← All questions
Coding
Minimum length subarray with sum k
Asked at
Delhivery
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 whether target is exact or at least k
- 02Ask whether negatives are permitted
- 03Use shrinking window for positive at-least version
- 04Use prefix sums for exact sum
- 05Use monotonic prefix deque for negative at-least version
Reference answer
Then expect these follow-ups
Why do negatives break the shrinking-window proof?
Tests: correctness reasoning
Which prefix index should be stored for exact-sum minimum length?
Tests: follow-up reasoning
Hiring now
Backend engineer roles are open right now
landed applies to roles like these for you, on each company’s own site, with answers written for the role.
Get 5x interviews10 free auto-applies. No card.

Platform Engineer (Backend Infrastructure)
Focal Systems · Remote

Director of Backend Engineering
Coupang · Seattle, USA

Senior Software Engineer – Backend Platforms and Agentic & ML Systems
Socure · Remote
Next question