intquickSelect(vector<int>& nums, int bg, int ed, int targetInd) { if (bg >= ed) return nums[bg];
int randInd = bg + rand() % (ed - bg); int pivot = nums[randInd]; swap(nums[bg], nums[randInd]);
int left = bg; for (int i = bg + 1; i < ed; i++) { if (nums[i] < pivot) swap(nums[i], nums[++left]); } swap(nums[bg], nums[left]); // 找到目标下标,返回对应值 if (left == targetInd) return nums[left];