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.
Climbing the Leaderboard
Climbing the Leaderboard
Sort by
recency
|
2385 Discussions
|
Please Login in order to post a comment
JAVA15; import java.io.; import java.util.; import java.util.stream.*; import static java.util.stream.Collectors.toList;
class Result {
}
public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
}
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;
}
C# version with binary search: