This is basically a part 2 of the classic chunk-splitting problem, but the header constraint is where it gets interesting.
First, clarify the problem constraints: header size H, payload size P, and max chunk size C. Then derive the minimum number of chunks by considering whether the header and payload can share a chunk. The key is to check if H + P <= C (then 1 chunk) or if H + (C - H) <= C (always true, so header can share with some payload if H < C). Actually, the header can share a chunk with the beginning of the data if the header size is less than C, because then there is remaining space in the first chunk for some payload. The minimum number of chunks is then 1 + ceil((P - (C - H)) / C) if H < C, else ceil(H/C) + ceil(P/C) but header cannot be split, so if H > C, it's impossible? Wait, the problem says 'header cannot be split across chunks', so if H > C, it's impossible to fit the header in any chunk. So we assume H <= C. Then the minimum chunks is 1 + ceil((P - (C - H)) / C) if P > C - H, else 1. But if H = C, then no room for payload in first chunk, so chunks = 1 + ceil(P/C). So the answer depends on whether H < C and if there is remaining space. The candidate should explain the formula and edge cases.
Pro tip: Demonstrate awareness of real-world constraints: in networking, headers often have fixed sizes and chunk boundaries may be dictated by MTU; mentioning that you'd validate assumptions (e.g., H <= C) and handle edge cases (H = C, P = 0) shows maturity.
Define H (header size), P (payload size), C (max chunk size). State assumptions: H <= C (otherwise impossible), and chunks are contiguous.
The header can share a chunk with the beginning of the data if H < C, because there is remaining space (C - H) in the first chunk for payload. If H = C, no sharing is possible.
If H < C: first chunk holds header and min(P, C-H) payload. Remaining payload = max(0, P - (C-H)). Additional chunks = ceil(remaining / C). Total = 1 + additional. If H = C: total = 1 + ceil(P/C).
Consider P = 0 (only header, 1 chunk), H = C (no sharing), and H > C (impossible). Also consider if P fits entirely in first chunk (total = 1).
State the formula clearly and test with examples (e.g., H=10, P=100, C=20 -> first chunk 10+10=20, remaining 90 -> 5 chunks, total 6).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.