You are viewing a single comment's thread. Return to all comments →
Here is my solution in C++:
vector<int> climbingLeaderboard(vector<int> ranked, vector<int> player) { vector <int> result; auto start = unique(ranked.begin(), ranked.end()); ranked.erase(start, ranked.end()); sort(ranked.begin(), ranked.end()); int index = 0; for (auto it : player) { while (index < ranked.size() && it >= ranked[index]) index++; result.push_back(ranked.size() - index + 1); } return result; }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Climbing the Leaderboard
You are viewing a single comment's thread. Return to all comments →
Here is my solution in C++: