Arrange crops into connected regions of a garden

0
Remix

A rectangular garden has N rows and M columns, and there are K crop types. Crop i must take exactly count[i] cells, and the counts add up to N * M. Return any planting that uses every cell once and keeps each crop in a single connected region.

A later part asks the same for a garden made of two squares instead of one rectangle.

GoogleCodingLast asked Aug 2026
No answer yet. Write the first one; the best answer gets endorsed.