Portfolio

Sum_Of_Two_Lowest_Positive_Integers


/*Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 integers.
No floats or empty arrays will be passed.

For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7.

[10, 343445353, 3453445, 3453545353453] should return 3453455.

Hint: Do not modify the original array.
*/


long sumTwoSmallestNumbers(std::vector<int> numbers)
{
sort(numbers.begin(), numbers.end());
unsigned int i=0, sum =0;
sum = (unsigned)numbers[i] +(unsigned)numbers[i+1];
return sum;
}