Two Pointers & Sliding Window
A lot of array and string problems ship with an obvious answer that reads every pair: two loops, one nested inside the other, quadratic time. Two pointers and sliding window are the two habits that fold that double loop into a single walk across the data. Both keep a couple of indices moving forward and lean on one promise: whatever ground a pointer has already passed, it never has to revisit. That promise is what buys you the drop from O(n squared) to O(n). In a Walmart loop, that drop is the bar.
The two techniques split by how the indices move. Two pointers can converge from opposite ends toward the middle, or run in the same direction at different speeds. A sliding window is a specialized same-direction pair where the gap between the pointers is what you care about. It is a contiguous stretch you widen and narrow to hunt for the best or smallest run that obeys some rule. Name which movement the problem wants, and the skeleton writes itself. The wrinkle the problem wraps around that skeleton is where your interview minutes should go.
- 4 problems, worked step by step
- about 32 min
Premium lessonWalmart interview guide
These took digging.
What candidates walked out with, from 20,000+ reports, forum threads behind logins and write-ups in Chinese. Then solved step by step.
100 companies. Checked every month.
Unlock all 100 companies$49 a year · less than $1 a week · Cancel anytime
Walmart interview guideKnow what Walmart asks before you walk in.
24 coding · 4 system design · 20 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.