Contact: aviboots(AT)netvision.net.il
39,954 questions
51,896 answers
573 users
function printNLargest(arr : any, N : number) { arr.sort((a, b) => b - a); for (let i = 0; i < N; i++) console.log(arr[i]); } const arr = [ 50, 99, 20, 100, 76, 33, 87, 40, 80, 86 ]; const N = 4; printNLargest(arr, N); /* run: 100 99 87 86 */