Untitled
unknown
plain_text
a year ago
524 B
9
Indexable
for (int i = 0; i < arr.size(); i++) {
int currentNum = arr.get(i);
int remainingSum = totalSum - currentNum;
// Check if the element after removing the current number is a potential outlier
// i.e., if the remainingSum is NOT equal to (currentNum * 2)
if (remainingSum % 2 == 0 && numbers.contains(remainingSum / 2)) {
continue;
} else {
greatestOutlier = Math.max(greatestOutlier, currentNum);
}
}Editor is loading...
Leave a Comment