intpick(int target){ int res = -1, count = 0; for (auto it = b; it != e; ++it) { if (*it != target) continue; if (rand() % ++count == 0) { res = distance(b, it); } } return res; }
vector<int>::iterator b, e; };
/** * Your Solution object will be instantiated and called as such: * Solution obj = new Solution(nums); * int param_1 = obj.pick(target); */