Associative array duplicate items

Hi,

  1. If I have an associative array with elements {1,3,8,6,7,3} and if I want to find the duplicated elements, how many are duplicated and in what indexes, Is there an efficient way to find out rather than comparing all the elements one by one.
  2. If there is an array like {5,5,2,2,321,567,765,5} - How can I find the duplicate values for this array.

Please let me know if there’s any other way to solve the array duplication problems other than comparing every element.

Thanks in advance.

In reply to sk7799:

module find_unique();
  int index;
  int array[100] = {15, 3, 12, 8, 8, 6, 8, 3, 4, 6, 14, 0, 0, 14, 4, 5, 10, 7, 0, 7, 8, 7, 2, 11, 15, 11, 13, 0, 8, 6, 9, 7, 2, 6, 10, 15, 9, 4, 6, 1, 8, 6, 8, 5, 9, 6, 14, 7, 6, 11, 1, 0, 4, 0, 2, 2, 6, 13, 7, 12, 10, 15, 12, 6, 7, 1, 5, 10, 10, 14, 1, 3, 4, 8, 11, 6, 7, 10, 0, 11, 4, 11, 6, 1, 15, 8, 14, 3, 14, 4, 2, 3, 14, 3, 11, 4, 4, 12, 1, 10};
  int assoc_array[int];
  
  initial begin
    for(index=0; index < 100; index++)begin
      // The array values will become the index and will tell the number of duplicate entries at particular index.
      assoc_array[array[index]]++;
    end
    $display( "%0d entries", assoc_array.num );
    foreach(assoc_array[index])
      $display("value at index:%d is %d", index,assoc_array[index]);
    
    
    $display("value of associative array:%p",assoc_array[index]);
  end
endmodule