← 返回 snapchat 的题目列表Probability Sampling
类型:online_judge
Design an algorithm to implement random sampling. Given an integer array containing n elements, implement a method to return one of them in a random order. Ensure each element has an equal probability of being selected. Provide code implementation and test cases. Data scale: Array length does not exceed 10000, with non-negative integer elements.
Example
Input
[1, 2, 3, 4, 5]