Sum Of Max And Min
You are given an array “ARR” of size N. Your task is to find out the sum of maximum and minimum elements in the array.
Follow Up:
Can you do the above task in a minimum number of comparisons?
Input format:
The first line of input contains a single integer T, representing the number of test cases.
Then the T test cases follow.
The first line of each test case contains a single integer N representing the size of the array 'ARR'.
The second line of each test case contains N space separated integers representing the elements of the array “arr”.
Output format:
For each test case, print the sum of the maximum and minimum element of the array 'ARR'.
Note:
You do not need to print anything. It has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 10
1 <= N <= 10^5
-10^9 <= ARR[i] <= 10^9
Time limit: 1 second
Be the first one to answer
Add answer anonymously...
Top SAP Senior Software Developer interview questions & answers
Popular interview questions of Senior Software Developer
Top HR questions asked in SAP Senior Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app