• + 0 comments

    Python Method : Using bisect to find the insert point and also is the new rank. However, sorted array must be the ascending because of bisect. Thus, I first delete duplicated scores so that rank number can be corresponding to the len(ranked)-index, and then re-sort it. Next, use bisect_right to find the insert point. When you get the insert point, you need to plus one for correcting rank number (rarher than index value).

    import bisect
    def climbingLeaderboard(ranked, player):
        ranked = sorted(list(set(ranked)))
        new_ranked = []
        for i in player:
            new_ranked.append(len(ranked)-bisect.bisect_right(ranked, i)+1)
        return new_ranked