DescriptionQ289
Q289FWASIC interview problem
Remove duplicates while preserving order
TechniquesSystemVerilogDeduplicationAssociative setStable filter
DifficultyEasy
TopicArrays
LanguageSystemVerilog
Requirements3 checkpoints
01
Problem
Remove duplicate integers from a sequence while preserving the first occurrence of every value in its original order.

Function headerSystemVerilog
function automatic void remove_duplicates(ref int in[$], ref int out[$]);Example input and output
Use this case to check your interpretationInput
values=[3,1,3,2,1,4]Output
[3,1,2,4]Explanation
Only the first occurrence of each integer is emitted, so the original encounter order is preserved.
02
Requirements (3)
- Clear any previous output.
- Emit a value only on its first appearance.
- Preserve first-occurrence ordering.
