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.
Finally managed to crack it after persevering so many times..
Here is my C++ solution.
1. I have converted the ranking vector to a set , to remove duplicates, thus giving me the actual ranking order, i.e. 1 to size of set
2. I have converted the set back to a vector to get the index position if we were to insert Alice's score, using lower_bound , remember lower_bound returns an iterator past the index
3. I work out potential idices and push them to the res vector.
4. I also check existing items in both ranking/player.. the code follows here..
Climbing the Leaderboard
You are viewing a single comment's thread. Return to all comments →
Finally managed to crack it after persevering so many times.. Here is my C++ solution. 1. I have converted the ranking vector to a set , to remove duplicates, thus giving me the actual ranking order, i.e. 1 to size of set 2. I have converted the set back to a vector to get the index position if we were to insert Alice's score, using lower_bound , remember lower_bound returns an iterator past the index 3. I work out potential idices and push them to the res vector. 4. I also check existing items in both ranking/player.. the code follows here..
vector climbingLeaderboard(vector &ranked, vector player) { vector res;
}