You are viewing a single comment's thread. Return to all comments →
TypeScript:
function climbingLeaderboard(ranked: number[], player: number[]): number[] { const rankings: number[] = []; const distinct: number[] = Array.from(new Set(ranked)); player.forEach((score) => { if (score < distinct[distinct.length - 1]) { rankings.push(distinct.length + 1); } else { for (let i = 0; i < distinct.length; i++) { if (score >= distinct[i]) { rankings.push(i + 1); break; } }; } }); return rankings; }
Seems like cookies are disabled on this browser, please enable them to open this website
Climbing the Leaderboard
You are viewing a single comment's thread. Return to all comments →
TypeScript: