← 返回 amazon 的题目列表Minimum Groups with Max-Min Difference Less Than Gap
类型:online_judge
amazon
Given an array and an integer gap, group the array with the minimum number of groups such that in each group, the difference between the maximum and minimum element is less than gap. For example, given the array [1,2,3,4,4,7] and gap = 2, a possible grouping is [1,2], [3,4,4], [7]. Calculate the minimum number of groups.
Example
Input
1,2,3,4,4,7
2