Recap: Check When You Marked Each Visit

Every graph problem in this section came down to two decisions: how to look up a node’s neighbors, and when to mark a node as visited. Here’s the question that cracked each one:

Exercise The question that unlocked it
Can This Package Reach That One? Which packages have I already checked, and where do I keep that so the check is instant?
Paint-Bucket Fill on a Pixel Grid Which pixels have I already handled, and does my copy share any row with the original?
Fewest Moves Through a Game Map Does my walk finish every tile one move away before it looks at tiles two moves away?
Review an AI-Written Connection Finder Which of these lines would break on an input the AI never tried?
Detect a Circular Import Is this module still in progress on my current path, or did I already finish it?

A quick self-check: think of the test that stayed red the longest for you. Which assumption in your code did it break? Interviewers often ask exactly that kind of question, and it’s a lot easier to answer once you’ve talked it through.

Want a second pair of eyes on your Graph work?

Every graph here treated each step as equal. In the Heaps section, some items matter more than others, and you’ll need a structure that always hands you the most important one next.

Become a Member to join the conversation.