Sum of largest elements
Sum of largest elements easy asked in interviews by 2 companies Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Sum of largest elements easy asked in interviews by 2 companies Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement:
Given an array of N integers, Find the sum of the Four largest numbers of the array and print it. Input The first line contains n. The next line contains n space-separated integers.
Constraints 4 ≤ n ≤ 105 1 ≤ arr[i] ≤ 109 Output A single integer denoting the sum. Example Input: 6 3 1 6 9 4 6
Output: 25
Explanation : 6 + 9 + 4 + 6 = 25
link: