You are viewing a single comment's thread. Return to all comments →
Java Solution
public static List<Integer> climbingLeaderboard(List<Integer> ranked, List<Integer> player) { List<Integer> rankList = ranked.stream().distinct().sorted().collect(Collectors.toList()); List<Integer> results = new ArrayList<>(); for (int playerScore : player) { int i = Collections.binarySearch(rankList, playerScore); if (i >= 0) results.add(rankList.size() - i); else results.add(rankList.size() + 1 - Math.abs(i + 1)); } return results; }
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 →
Java Solution