• + 2 comments

    You can sort the numbers in nlogn time assuming you use quicksort, and since the size will always be 5, you can add the values in constant time. You just add the first four to get the smallest sum, and the last 4 to get the largest sum.