Hardware interview practice
Find a missing packet sequence ID
After start, consume n distinct sequence IDs drawn from the inclusive range 0 through n and report the one missing value using constant word-sized state.
Reviewed example
Work through one case
Input
n=4; accepted distinct sequence IDs=[4,1,0,3]Expected output
missing_id=2XOR or widened-sum constant state compares the complete 0..4 range with exactly four accepted IDs, including boundary values zero and n.
What to cover
Requirements
- Use no bitmap or external memory.
- Complete after exactly n accepted IDs and handle missing zero or missing n.
- For n equal to zero, return zero without waiting for input data.
- Hold the result until accepted and do not advance the count during input stalls.
