You are viewing a single comment's thread. Return to all comments →
A longer C++ solution:
vector<int> climbingLeaderboard(vector<int> ranked, vector<int> player) { vector<int> result; size_t r_ind = 0; int place = 0; result.resize(player.size()); for (size_t p_ind = player.size(); p_ind-- > 0;) { int old_ranked = -1; while (r_ind < ranked.size() && ranked[r_ind] > player[p_ind]) { if (old_ranked != ranked[r_ind]) { place++; } old_ranked = ranked[r_ind]; r_ind++; } result[p_ind]= place + 1; } return result; }
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 →
A longer C++ solution: