You are viewing a single comment's thread. Return to all comments →
I aimed to make the code traverse both lists only once, and this was the result. Any suggestions for improvement?
def climbingLeaderboard(ranked, player): ranked = sorted(set(ranked), reverse=True) player = sorted(player, reverse=True) player_ranks = [] i = 0 for p in player: while i <= len(ranked): if i == len(ranked): player_ranks.append(i + 1) break elif p >= ranked[i]: player_ranks.append(i + 1) break i += 1 return sorted(player_ranks, reverse=True)
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 aimed to make the code traverse both lists only once, and this was the result. Any suggestions for improvement?