Hardware interview practice
Compare packet-symbol multisets
Determine whether two bounded packet descriptors contain the same 4-bit symbols with the same multiplicities, regardless of ordering.
Reviewed example
Work through one case
Input
A length4=[1,2,1,3]; B length4=[3,1,2,1]; inactive suffixes contain unrelated dataExpected output
same_multiset=1Both active prefixes have counts {1:2,2:1,3:1}; ordering and inactive lanes do not affect the 16-bin comparison.
What to cover
Requirements
- Support active lengths from zero through MAX_LEN and ignore inactive slots.
- Treat the 4-bit alphabet as exactly 16 possible symbols.
- Return false immediately in the logical result when lengths differ.
- Capture each request while idle and clear all per-request counting state.
