Copy a Sub-Rectangle Within a Grid In Place

Asked at Waymo · Coding Questions · Difficulty: Medium · Last asked Jan 23, 2026

Copy a rectangular block of cells inside a 2-D array to another position of the same array, in place. The source block and the destination block may overlap, so the order in which cells are copied matters: a cell must be read before a later write can overwrite it.

Loading the problem…