Graphs, Grids & Topological Sort
Four of these problems trace the same move: stand on a node, look at its neighbors, and walk outward until you have seen everything you can reach. A grid is a graph. Each cell is a node wired to the four cells beside it, so a Premium question-counting and a Premium problems are traversals with the edges left implicit. A Premium question and word transformation hand you the graph more openly, one as a set of prerequisites and the other as a web of one-letter edits. Learn the walk once and all four fall to it.
The walk comes in two temperaments. Breadth-first fans out in rings, nearest nodes first, which is why it answers any shortest-path question on an equal-weight graph without ever comparing distances. Depth-first plunges down one branch to its end before backing up, which suits flood-fill and cycle-hunting. The same visited discipline sits under both: mark a node the moment you queue it, never when you leave it, or the same cell rejoins the frontier and the count doubles. Topological sort is the one that looks different, and it is really a breadth-first walk over a dependency graph, releasing a task only once every task it waits on has gone.
- 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.