What does same probability mean?


  • 0
    E

    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?


  • 0

    @eundoo.song said in What does same probability mean?:

    I saw all of you here used random function to return an element randomly.
    How this can be the same probability?

    Why would it not?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.