Count Same-Color Squares in an Unbounded Grid

Asked at Waymo · Coding Questions · Difficulty: Medium · Last asked May 6, 2026

Phone screen on a 2-D grid whose cells carry color labels A / B / C / D. Count the number of axis-aligned squares formed by connected same-color cells. Grid has no a-priori size bound — the data structure must handle sparse cell sets.

Loading the problem…