// const scores = [100, 100, 100]; // 3 const scores = [30,1,30,30]; // 3 const n = scores.length; let res = 0; const tmp = []; for(let i=0;i<n;i++){ tmp.push(scores[i]); } tmp.sort((a,b)=>a-b); for(let i=0;i<n;i++){ let lastIndex = tmp.lastIndexOf(scores[i])+1; let left = n-lastIndex; if (lastIndex>left){ res++; } } console.log(res);