We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Remove duplicates in ranked array and then sort the player array in descending order. iterate through ranked array until find the point which is less than the player's, and append the (index + 1) into the result array. Finally sort the result in descending order.
defclimbingLeaderboard(ranked,player):# Write your code hereplayer.sort(reverse=True)res=[]index=0ranked=list(dict.fromkeys(ranked))foriinplayer:whileindex<len(ranked)andranked[index]>i:index+=1ifindex>=len(ranked):index=len(ranked)res.append(index+1)continueres.append(index+1)res.reverse()returnres
Cookie support is required to access HackerRank
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 →
Remove duplicates in ranked array and then sort the player array in descending order. iterate through ranked array until find the point which is less than the player's, and append the (index + 1) into the result array. Finally sort the result in descending order.