You are viewing a single comment's thread. Return to all comments →
// java easy understandable Code
public static List climbingLeaderboard(List ranked, List player) { // Write your code here List list = new ArrayList<>(); // answer storage
Stack<Integer> st = new Stack<>(); //store distinct ranked in order asc for(int i:ranked){ if(st.size() == 0 || st.peek() != i){ st.push(i); } } // while poping out ranks give rank to the players for(int i: player){ while(st.size()>0 && st.peek()<=i){ st.pop(); } list.add(st.size()+1); } return list; }
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 easy understandable Code
public static List climbingLeaderboard(List ranked, List player) { // Write your code here List list = new ArrayList<>(); // answer storage