Sum of smallest elements
Sum of smallest elements easy asked in interviews by 1 company Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Sum of smallest elements easy asked in interviews by 1 company Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement:
Given an array of N integers, find the 4 smallest number of the array and print their sum. Input First line contains n. 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 1
Output: 9
Explanation : 3 + 1 + 4 + 1 = 9
link: