Code Room
CodingHardcod-g1033
Subject Protocol internet checksumLevel Mid–Senior~25 minCommon in Networking & APIs · Algorithms & data structures interviewsIndustries Software development, Telecom

Question

Compute the 16-bit Internet checksum (RFC 1071) over a list of byte values. Treat the data as a sequence of 16-bit big-endian words; if the byte count is odd, pad with a single trailing zero byte. Sum the words in ones-complement arithmetic (fold any carry out of bit 15 back into the low bits), then return the bitwise complement of the final sum, masked to 16 bits. An empty input yields 0xFFFF.

Implement
internet_checksum(data: list[int]) → int
Examples
in[[0,1,242,3]]out3579
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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.