1
class Solution {
2
Random random;
3
int[] origin;
4

5
public Solution(int[] nums) {
6
random = new Random();
7
origin = nums;
8
}
9

10
public int pick(int target) {
11

12
while (true) {
13
int idx = random.nextInt(origin.length);
14
if (origin[idx] == target) {
15
return idx;
16
}
17
}
18
}
19
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0