Question: Given an array of integers, determine if any element is an outlier. An outlier is a number that is neither in the original array nor

Given an array of integers, determine if any element is an outlier. An outlier is a number that is neither in the original array nor the sum of the other elements in the array. Find the largest outlier if one exists.
Input:
arr: An integer array.
Output:
The largest outlier in the array, or -1 if no outlier exists.
Example:
arr: [4,1,3,16,2,10]
Output: 16
Task:
Write a function that takes the arr array as input and returns the largest outlier, or -1 if no outlier exists.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!