← 返回 amazon 的题目列表Maximize Sum of Intervals Containing At Least Two Elements
类型:online_judge
amazon
Given an integer array, write a function to sort it and then solve the following problem using a greedy algorithm: select the minimum number of intervals such that each interval contains at least two elements and the sum of the selected intervals is maximum. Provide function signature, algorithm complexity, and necessary test cases.
Example
Input
[1, 3, 2, 5, 4]