← Questions

Copy a rectangle within a 2D array in place

0
WaymoCodingLast asked Sep 2026

Given a 2D array, a rectangular block (top-left corner, height, width) and a destination for its top-left corner, copy the block to the destination with O(1) extra memory. The source and destination may overlap, so choose the copy direction (rows and columns, forward or backward) the way memmove does.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding