I have an array, A = [a1,a2,a3,...aP] with size P. I have to sample q elements from array A.
A = [a1,a2,a3,...aP]
P
q
I plan to use a loop with q
You may construct second array, boolean with size P and store true for picked numbers. And when the numer is picked, check second table; in case "true" you must pick next one.