You are viewing a single comment's thread. Return to all comments →
Python 3, no sorting, no extra memory
def climbingLeaderboard(ranked, player): result = [] i = 0 currplace = 1 pindx = len(player) - 1 ranked.append(0) while i < len(ranked): if pindx < 0: return result lastsc = ranked[i] if player[pindx] >= ranked[i]: result .insert(0, currplace) pindx -= 1 else: i += 1 if ranked[i] != lastsc: currplace += 1 return result
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Climbing the Leaderboard
You are viewing a single comment's thread. Return to all comments →
Python 3, no sorting, no extra memory