Implement parallel chunk download: fetch multi-part data concurrently, keep chunk order, pack the resulting bytes into a structured payload, and verify file assembly. Code must actually run (Python).
Asked in the Technical phone screen stage. Implement assemble_payload(chunks, expected_data), where chunks is an ordered list of byte-value lists and expected_data is the complete byte-value list. Return {"length": int, "payload": list[int]}. The payload must contain a four-byte big-endian length prefix followed by the assembled bytes. Raise ValueError if the assembled bytes do not match expected_data or if payload verification fails.
Example: [[65], [66, 67]] and [65, 66, 67] produce { "length": 3, "payload": [0, 0, 0, 3, 65, 66, 67] }.
Constraints: at most 1,000 chunks, each byte is in 0..255, and chunk order must be preserved.
def assemble_payload(chunks, expected_data):