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.
publicstaticList<Integer>climbingLeaderboard(List<Integer>ranked,List<Integer>player){// Unique set sorted according to the natural ordering of its elementsTreeSet<Integer>rankedSet=newTreeSet<>(ranked);ArrayList<Integer>result=newArrayList<>();for(Integerscore:player){while(!rankedSet.isEmpty()&&score>=rankedSet.first()){rankedSet.pollFirst();}result.add(rankedSet.size()+1);}returnresult;}}
Cookie support is required to access HackerRank
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: