class Solution {
public:
vector<int> res;
Solution(vector<int>& nums) {
res = nums;
}
int pick(int target) {
int c = 0;
int index = 0;
for (int i = 0; i < res.size(); ++i){
if (res[i] == target){
c++;
if (rand() % c == 0) index = i;
}
}
return index;
}
};