InterviewLegend

Graphs, Grids & BFS

Alex Chen35 min readUpdated 43 real interview reports

Two of the Pinterest onsite reports that name a graph problem name a grid one: shortest path through a grid with a limited number of obstacles you may knock down, and the bus-routes BFS. Add the board-dependency ordering that shows up in product-flavored phrasing and you have the shape of this cluster. It leans on breadth-first search and topological sort more than on heavy DFS recursion. Drill accordingly.

None of this is Pinterest-specific algorithmically. It is the standard graph kit every FAANG loop draws from, occasionally reframed in Pin and board language. So own three templates cold: grid BFS for shortest paths, a multi-source BFS wavefront, and Kahn's topological sort. Let the product framing wash over them. When the prompt says "order the boards so each one is built after the boards it pulls from," your hands should already be reaching for indegree counts before the interviewer finishes the sentence.

The Pinterest angle
Say "BFS, because the edges are unweighted, so the first time I reach a cell is the shortest way to it" before you write a line. On a grid where every step costs one, breadth-first search is optimal and Dijkstra is overkill. Say so. It's a cheap signal that you know why BFS works here. The one twist Pinterest's reported grid problem adds is a budget: you may eliminate up to k obstacles. That budget belongs in the visited state alongside the position. Candidates who miss this mark a cell visited by coordinates alone, then wrongly refuse to revisit it with more budget left. Call out the state shape, (row, col, obstacles_remaining), and you have shown you see the trap.
What's inside
  • 2 problems, worked step by step
  • about 35 min

Premium lessonPinterest 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

Had your Pinterest interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Pinterest interview guide

Know what Pinterest asks before you walk in.

14 coding · 5 system design · 16 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.