private void swap(int[] a, int i, int j) {
        int temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }
This is quick select algorithm and average time complexity is O(N).
We use k as a pivot.
src/problems/medium/KthLargestElementinanArray.java