```
class Solution {
public:
vector<int> Res;
Solution(vector<int> nums)
:
Res(nums.begin(),nums.end())
{
srand(time(NULL));
}
int pick(int target)
{
int i = 0;
int j = Res.size();
int Idx = 0;
while(i < j)
{
Idx = (rand() % (j - i));
if(Res[Idx] == target)
{
break;
}
swap(Res[Idx],Res[j - 1]);
j--;
}
return (Idx);
}
};
```