Mini-Max Sum
EasyP3Coding
Given an array of five positive integers, choose exactly four of them. Return [minSum, maxSum]: the smallest and the largest sum that four of the five integers can give.
Example 1
- Input
- nums = [1,2,3,4,5]
- Output
- [10,14]
- Why
- Leave out 5 to get 10, leave out 1 to get 14.
Example 2
- Input
- nums = [5,5,5,5,5]
- Output
- [20,20]
Example 3
- Input
- nums = [1,1,1,1,1]
- Output
- [4,4]
Constraints
- nums.length == 5
- 1 <= nums[i] <= 10^9
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.