3/32
Part 1 of 7 · A grid is a graphLearn and do

A cell has at most four edges, so a search that touches each cell and edge once is O(RC)

You never build an edge list. Four offsets and a bounds check produce a cell's edges when you ask for them. Here are all the edges of that 3 by 4 grid:

Predict

A 3 by 4 grid. How many edges join two cells that share a side?

Pick an answer above to see the rest