Company: amazon_23april
Difficulty: medium
AWS Outlier Detection Service AWS provides many services for outlier detection. A prototype small service to detect an outlier in an array of integers is under development. Given an array of n integers, there are (n - 2) normal numbers and the sum of the (n - 2) numbers originally in this array. If a number is neither in the original numbers nor is it their sum, it is an outlier. Discover the potential outliers and return the greatest of them. Note: It is guaranteed that the answer exists. Input Format An array arr[n] containing integers representing the value of (n-2) numbers, their sum, and outlier value. Output Format Return an integer representing the outlier value. Constraints 3 ≤ n ≤ 10 5 1 ≤ arr[i] ≤ 10 9 Examples Example 1: Input: n = 6 arr = [4, 1, 3, 16, 2, 10] Output: 16 There are two potential outliers: Remove 16 - arr\' = [4, 1, 3, 2, 10]. The sum of [4, 1, 3, 2] is 10, so 16 is a potential outlier. Remove 4 - arr\' = [1, 3, 16, 2, 10]. The sum of [1, 3, 2, 10] is 16, so 4