The pattern challenge is back again with more complexity. Write a program to find the sum of the smallest
and largest element of the array.
Example:
Input: n = 3, arr = [2224,5262,223]
Output: 5485
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){long long n = 3;long long arr[n] = {2224, 5262, 223};sort(arr, arr + n);cout << arr[0] + arr[n - 1];return 0;}
No comments:
Post a Comment