HackerRank: Mini-Max Sum

[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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s