Chunk checksum verification

Write codeMedium25 min

Your task

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.

Examples

verify_chunks(chunks: list[str], expected: list[int]) -> list[int]
Example 1
Inputverify_chunks(["abc", "abc"], [38600999, 1])
Output[1]