Code RoomChunk checksum verification
MediumPrep Room Coding #216

Chunk checksum verification

CodingStorage & CDNMid–Senior~25 min

Verify on-disk chunk integrity. A file is split into chunks; you are given two parallel lists: `chunks` (each a string of bytes) and `expected` (each an integer checksum that was stored when the chunk was written). The checksum of a chunk is defined deterministically as the Adler-32-style rolling sum: a = 1, b = 0; for each byte v of the UTF-8 encoding, a = (a + v) mod 65521 and b = (b + a) mod 65521; the checksum is (b * 65536 + a). Recompute each chunk's checksum and return a list of the 0-based indices of all chunks whose recomputed checksum does NOT match its expected value (i.e. corrupted chunks), in ascending index order. The two lists have equal length <= 10^4.

Implement
verify_chunks(chunks: list[str], expected: list[int]) → list[int]
Examples
in[["abc","abc"],[38600999,1]]out[1]
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 25 min
InputExpectedGot
[["abc","abc"],[38600999,1]][1]not run yetsample