@@ -0,0 +1,454 @@
+// TODO: use reservoir sampling %0Apublic class Solution %7B%0A  int%5B%5D nums;%0A%0A  public Solution(int%5B%5D nums) %7B%0A    this.nums = nums;        %0A  %7D%0A%0A  public int pick(int target) %7B%0A    List%3CInteger%3E list = new ArrayList%3CInteger%3E();%0A    for (int i = 0 ; i %3C nums.length; i ++ ) %7B%0A      if (this.nums%5Bi%5D == target) %7B%0A        list.add(i);%0A      %7D%0A    %7D%0A%0A    int length = list.size();%0A    int random = (int)(Math.random() * length);%0A    return list.get(random);%0A  %7D%0A%7D%0A

Add leetcode 398