In reply to sasi_8985:
This is more like a puzzle (code will need comments for others to understand) Based on your definition, I can’t be sure what classifies as “array manipulation methods” and what does not. Am i forced to use them ? Or can I ignore them if i chose to ?
I didn’t chase fixing your code.
Speaking for efficiency, the below 1-pass method looks more efficient. Of course, I am using a helper Associative Array here. (You can avoid the helper associate array, and chose to do a unique at the end, like in your code).
module tb;
int c[$] = '{1,3,1,2,3,6};
int fin[$];
int y;
int a[int];
initial
begin
foreach(c[i]) begin
if(a.exists(c[i])) begin
if(a[c[i]]==1) begin fin.push_back(c[i]); a[c[i]]=2; end
if(a[c[i]]==2) continue;
end
else a[c[i]]=1;
end
$display("%p",fin);
end
endmodule