You are viewing a single comment's thread. Return to all comments →
Linear solution for python
def climbingLeaderboard(ranked, player): res = [] d = {} lowest = player[0] tmp = None n = 1 for rank in ranked: if lowest >= rank: break if not tmp or rank != tmp: d[n] = rank n +=1 tmp = rank res.append(n) d[n] = lowest for score in player[1:]: while n > 0 and d[n] <= score: n -= 1 n += 1 d[n] = score res.append(n) return res
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 →
Linear solution for python