Spot the graph in the story
transcript
An interview problem never says graph. It talks about an org chart. Or racks on a warehouse floor. The graph is hiding.
In an org chart, the people are the nodes. Reporting lines are the edges. Stored as arrays of children, it is a tree.
Each rack cell is a node. Its neighbours up, right, down and left are its edges. A block is one connected piece.
Each build step is a node. Needs another step? That is an edge. Mind which way each edge points.
Rows of a tree? Use a queue. Blocks of cells? Flood fill each one. An order of steps? Topological sort.
In the interview, say the model first. Name the nodes, the edges and the direction. It shows the interviewer your thinking. And it catches a wrong direction early.
Find the graph in the story. Then let the question pick the walk. Full breakdown in the lecture.