How can I create a dynamic array with different random values in random size?
<p>Interview question:
I have a systemverilog based class as following:</p>

<pre><code>class A;
rand n;
constraint c:{n&gt;=10 &amp;&amp;n&lt;=15};
bit [31:0] arr[];
randc [31:0] data;
endclass
</code></pre>

<p>In this case 'n' is the size of the dynamic array arr. And the question is how to write a method to create the array so that all the elements in this array is different from each other. </p>

<p>So the problem is randc type can only make sure each time I instantiate the class, I get a different value, but how can I store those value in an array like this? Any help is appreciated.</p>

<p>P.S. There may be mistakes in the class and it is editable.</p>