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.
I finally wrote a code faster, better and more destructive than the AI chatbot generated. Have a look. Python. But it is so simple you can transplant it to anything.
def climbingLeaderboard(ranked, player):
ranked = sorted(list(set(ranked)), reverse=True)
ans = []
for p in player:
while len(ranked) > 0 and ranked[-1] < p:
ranked.pop()
if len(ranked) == 0:
ans.append(1)
elif ranked[-1] == p:
ans.append(len(ranked))
else:
ans.append(len(ranked)+1)
return ans
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 →
I finally wrote a code faster, better and more destructive than the AI chatbot generated. Have a look. Python. But it is so simple you can transplant it to anything.
def climbingLeaderboard(ranked, player):