type Solution struct {
index map[int][]int
}
func Constructor(nums []int) Solution {
sol := Solution{index: make(map[int][]int)}
for i, n := range nums {
sol.index[n] = append(sol.index[n], i)
}
return sol
}
func (this *Solution) Pick(target int) int {
arr := this.index[target]
return arr[rand.Intn(len(arr))]
}
/**
* Your Solution object will be instantiated and called as such:
* obj := Constructor(nums);
* param_1 := obj.Pick(target);
*/