Quickselect K-th Smallest
Quickselect K-th Smallest
Given an integer array nums and an integer k (1-indexed), return the k-th smallest element.
Function signature
func QuickselectKth(nums []int, k int) int
Example
nums = [7,2,1,8,6,3,5,4]
k = 3
output = 3
Constraints
- 1 <= len(nums) <= 200000
- 1 <= k <= len(nums)
- -1_000_000_000 <= nums[i] <= 1_000_000_000
Notes
- The array may be modified in-place.
Run tests to see results
No issues detected