• + 1 comment

    My Python code is unable to complete four testcases because it can't complete the task within the time limit. Can anyone hlep me optimize my code?

    def climbingLeaderboard(ranked, player):
        ranks = []
        for a in range(len(player)):
            ranked.append(player[a])
            ranked = list(reversed(sorted(list(set(ranked)))))
            ranks.append(ranked.index(player[a]) + 1)
        return ranks