FindKthMax returns the kth large element given an integer slice with nil `error` if found and returns -1 with `error` `search.ErrNotFound` if not found. NOTE: The `nums` slice gets mutated in the process.
(nums []int, k int)
| 9 | // with nil `error` if found and returns -1 with `error` `search.ErrNotFound` |
| 10 | // if not found. NOTE: The `nums` slice gets mutated in the process. |
| 11 | func FindKthMax(nums []int, k int) (int, error) { |
| 12 | index := len(nums) - k |
| 13 | return kthNumber(nums, index) |
| 14 | } |
| 15 | |
| 16 | // FindKthMin returns kth small element given an integer slice |
| 17 | // with nil `error` if found and returns -1 with `error` `search.ErrNotFound` |