[Get the question here]

My strategy: if you are trying to find the largest sum possible from adding 4 out of five numbers, the logical thing to do would be to exclude the smallest value of the five number. In contrast finding the smallest possible sum of 4 out of five numbers, you would want to exclude the largest of the five numbers.

Two two functions findMin and findMax are essentially identical expect for the boolean that the if-statement filters for.

Another strategy that would probably have the same time complexity but a larger space complexity would be to find all five possible sums of the 5permute4 of the values and then find the minimum sum and maximum sum of those 5 answers.

Required knowledge: Adhoc.

### Like this:

Like Loading...