You are viewing a single comment's thread. Return to all comments →
def getRank(arr, target): start = 0 end = len(arr) - 1 while start <= end: mid = (start + end) // 2 if target == arr[mid]: return mid + 1 elif target > arr[mid] and (mid == 0 or target < arr[mid-1]): return mid + 1 elif target < arr[mid]: start = mid + 1 else: end = mid return len(arr) + 1 def climbingLeaderboard(ranked, player): # Write your code here unique_ranked = [] previous = None for i in ranked: if i != previous: previous = i unique_ranked.append(i) ranks = [] for i in player: rank = getRank(unique_ranked, i) ranks.append(rank) return ranks
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 →