Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
524 B
2
Indexable
Never
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);
            }
        }
Leave a Comment