Find Duplicate Elements in an Array

AMD

Problem Description

You are given an array of integers. Write a SystemVerilog module that identifies all duplicate elements present in the array.

The module should scan the input array and return the duplicate values without printing or using any built-in unique/sort functions.

Example:

(a) Input Array:

arr = {5, 2, 7, 5, 9, 2, 10}

Expected Output:

output = {5, 2}

(b) Input Array:

arr = {7, 7, 7, 7}

Expected Output:

output = {7}

SystemVerilog

Code Editor Access

Log in to write, run and submit your solution to this interview question. It's free.

Output

Output goes here...