Back to problems

Tetris-Style Figure Placement

Algorithm · Capital One · Medium

Requirements You receive grid size n by m, along with an arrival sequence containing shapes from {A, B, C, D, E}; process that sequence in its given order. The occupied (1) and unoccupied (0) cells for the shapes are: A = [[1]] B = [[1, 1, 1]] C = [[1, 1], [1, 1]] D = [[1, 0], [1, 1], [1, 0]] E = [[0, 1, 0], [1, 1, 1]] Handle each incoming shape in sequence, assigning it a 1-based arrival label. Search candidate origins (r, c) from top to bottom and, within each row, from…

Checking your access…