Solve this in C++ with the following function signature Function Signature: #include…
- User
Solve this in C++ with the following function signature
Function Signature:
#include <bits/stdc++.h>- • Complete the 'getOutlierValue' function below. The function is expected to return an INTEGER. The function accepts INTEGER ARRAY arr as parameter. int getOutlierValue(vector arr) { 1 int main()-
- Code Question 2 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. Example n=6 arr[4, 1, 3, 16, 2, 10] 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. (It is not an original number or their sum.) • Remove 4-arr'= [1, 3, 16, 2, 10]. The sum of [1, 3, 2, 10] Is 16, so 4 is a potential outlier. The outlier is the greater of the two potential outliers, so 16 is the outlier. Function Description Complete the function getOutlierValue in the editor below. getOutlierValue has the following parameter(s): int arr[n]: value of (n-2) numbers, their sum, and outlier value Returns int: the outlier value Constraints • 3sns 105 • 1 s arr[i]s 109 Input Format For Custom Testing The first line contains an integer, n, the number of elements in arr. Each line / of the n subsequent lines (where 0s/<m) contains an integer, arr[i]. ▾ Sample Case 0 Sample Input For Custom Testing STDIN FUNCTION → arr[] size n = 6 arr 14, 1, 2, 1, 10, 31
Returns int: the outlier value Constraints • 3sns 105 • 1 s arr[i]s 109 Input Format For Custom Testing The first line contains an integer, n, the number of elements in arr. Each line / of the n subsequent lines (where 0s/<n) contains an integer, arr[i]. Sample Case O Sample Input For Custom Testing STDIN FUNCTION 6 → arr[] size n = 6 4 → arr = [4, 1, 2, 1, 10, 3] 1 2 1 10 3 Sample Output 1 Explanation The original list is [1, 2, 3, 4] with a sum of 10. ▼ Sample Case 1 Sample Input For Custom Testing STDIN FUNCTION 4 → arr[] size n = 4 2
- arr = [2, 2, 4, 2] 2 4 2 Sample Output 2 Explanation The original list is [2, 2) with a sum of 4.
- Assistant