Friday, 21 February 2020

Minimum-Max Sum

Minimum-Max Sum



Objective


Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly three of the five integers.


Description


For example, arr=[1,3,5,7,9] . Our minimum sum is 1+3+5+7 and our maximum sum is 3+5+7+9. We would print 
Min - 16
Max - 24


Code


Here’s my solution, with embedded comments:



I hope you found this helpful.
Cheers :)

No comments:

Post a Comment

Diagonal Difference

Diagonal Difference Objective Given a square matrix, calculate the absolute difference between the sums of its diagonals. Descripti...