picking the pivot in the most simple idiot way ever using (left + right) / 2. Anything that would involve Math.random would be more expensive since Math.random are expensive, a better option is to use ThreadLocalRandom because this generate random

in the running thread (not shared) only and doesn't concern itself with other threads

```
// a direct implementation of the algorithm found here
// https://en.wikipedia.org/wiki/Quickselect#Algorithm
public int findKthLargest(int[] nums, int k) {
int nthElementIndex = nums.length - k;
return select(nums, 0, nums.length - 1, nthElementIndex);
}
public int select(int[] nums, int left, int right, int nth) {
if(left == right)
return nums[left];
int pivotIndex = (left + right) / 2;
pivotIndex = partition(nums, left, right, pivotIndex);
if(pivotIndex == nth)
return nums[pivotIndex];
else if(pivotIndex > nth)
return select(nums, left, pivotIndex - 1, nth);
else
return select(nums, pivotIndex + 1, right, nth);
}
int partition(int[] nums, int left, int right, int pivotIndex) {
int pivotVal = nums[pivotIndex];
int ptr = left;
swap(nums, pivotIndex, right);
while(ptr < right) {
if(nums[ptr] < pivotVal) {
swap(nums, left, ptr);
left++;
}
ptr++;
}
swap(nums, left, right);
return left;
}
void swap(int[] a, int i, int j) {
int tmp = a[i];
a[i] = a[j];
a[j] = tmp;
}
```