Untitled
Collections.sort(xp); // Step 1: Sort the experience points
Set<Double> uniqueAverages = new HashSet<>(); // Step 3: Store unique
averages
int n = xp.size();
for (int i = 0; i < n / 2; i++) {
double average = (xp.get(i) + xp.get(n - 1 - i)) / 2.0;
uniqueAverages.add(average);
}
return uniqueAverages.size()
Leave a Comment
Please, sign-in to leave a comment.