nthlargest([ 43, 56, 23, 89, 88, 90, 99, 652], 4)
89
function nthlargest(arr, highest) {
// write your code here
return
}
const arr = [43, 56, 23, 89, 88, 90, 99, 652];
const highest = 4;
console.log(nthlargest(arr, highest));
- nthlargest([ 43, 56, 23, 89, 88, 90, 99, 652], 4) returns 89
- nthlargest([ 10, 100, 1000, 10000], 2) returns 1000
- Learn more about implementing MinHeap and MaxHeap here.