Skip to the selected question
ASIC.FYI

ASIC Interview Question Bank

1,000+ hardware interview questions.Curated and reviewed by industry engineers.1,000+ hardware questions1,000+ questionsEngineer-reviewed
DescriptionQ289
Page ↗
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.

Input sequence annotated as new or duplicate with blank stable-order output slots
Keep the first occurrence of each value and preserve the sequence's 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 interpretation
Input
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.