1class Solution {2Random random;3int[] origin;45public Solution(int[] nums) {6random = new Random();7origin = nums;8}910public int pick(int target) {1112while (true) {13int idx = random.nextInt(origin.length);14if (origin[idx] == target) {15return idx;16}17}18}19}