Code RoomCount bitmaps from runs
HardPrep Room Coding #4947

Count bitmaps from runs

CodingAlgorithms & data structuresMid–Staff~40 min

An icon editor stores a black and white bitmap by its run headers instead of its pixels. row_runs[r] lists, left to right, the lengths of the runs of dark pixels in row r, and col_runs[c] does the same top to bottom for column c. Runs in the same line are separated by at least one light pixel, and an empty header means that line has no dark pixels at all. The bitmap has one row per entry of row_runs and one column per entry of col_runs. Return how many bitmaps carry exactly these headers. Return 0 when none does. A bitmap with no rows and no columns has one header set, the empty one, so return 1 there. The bitmap is at most 6 rows by 7 columns and every run length is positive.

Implement
count_matching_bitmaps(row_runs: list[list[int]], col_runs: list[list[int]]) → int
Examples
in[[[1],[1]],[[1],[1]]]out2
in[[[3],[1,1],[3]],[[3],[1,1],[3]]]out1
in[[[1]],[[1],[1]]]out0
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 40 min
InputExpectedGot
[[[1],[1]],[[1],[1]]]2not run yetsample
[[[3],[1,1],[3]],[[3],[1,1],[3]]]1not run yetsample
[[[1]],[[1],[1]]]0not run yetsample