We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Climbing the Leaderboard
Climbing the Leaderboard
Sort by
recency
|
2308 Discussions
|
Please Login in order to post a comment
O(logN) - Java solution Tip: Use Binary Search since the data is sorted. public static List climbingLeaderboard(List ranked, List player) { // Write your code here List ranks = new ArrayList<>(); ranks.add(1); for (int i = 1 ; i < ranked.size() ; i++) { if (ranked.get(i) < ranked.get(i-1)) { ranks.add(ranks.get(i-1) + 1); } else { ranks.add(ranks.get(i-1)); } } List playerRanks = new ArrayList<>();
int[] arr = new int[1];
} return; } }
}
O(N) solution in C.
Solution in TypeScript. Complexity O(r), where r is the length of ranked array with O(p) space complexity.
python , simple and straightforward
def climbingLeaderboard(ranked, player): # Write your code here ranked = sorted(set(ranked), reverse=True)
def climbingLeaderboard(ranked, player):