This problem says,
Each element must have the same probability of being returned.
What does “same probability” mean?
Per my understanding of probability, to have the same probability,
getRandom should return each element in the same probability like
P(X) = 1/N (X = x1, x2, x3,…….xN)
I saw all of you here used random function to return an element randomly.
How this can be the same probability?
I get confused in understanding this sentence when I first read the problem and had no idea how to solve.
Did I misunderstand?