Sector XOR folding
A tape archive proves a restore by XOR folding the id of every sector it touched. starts and ends describe the runs in order: run i covers every sector id from starts[i] up to ends[i] inclusive, and a run whose start is greater than its end is a placeholder that covers nothing. Overlapping runs are normal, and a sector covered by two runs is folded in twice. Ids are below 2^30 and a single run can span hundreds of millions of sectors, so counting them one at a time is not an option. Return the XOR of every covered id, or 0 when the runs cover nothing at all. The two lists always have the same length.
archive_run_checksum(starts: list[int], ends: list[int]) → int[[1],[5]]out1[[0,10],[3,12]]out13[[7],[3]]out0State 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.
[[1],[5]]1not run yetsample[[0,10],[3,12]]13not run yetsample[[7],[3]]0not run yetsample