Climbing the Leaderboard

  • + 0 comments
    def climbingLeaderboard(ranked, player):
        ranked = sorted(set(ranked), reverse=True)  # Remove duplicates and sort in descending order
        ranks = []
        index = len(ranked) - 1  # Start from the lowest ranked
    
        for score in player:
            while index >= 0 and score >= ranked[index]:
                index -= 1  # Move up in the leaderboard
            ranks.append(index + 2)  # Append the rank
        return ranks