Maximum Tastiness of Candy Basket
You are given an array of positive integers price where price[i] denotes the price of the i^th candy and a positive integer k.
The store sells baskets of k distinct candies. The tastiness of a candy basket is the smallest absolute difference of the prices of any two candies in the basket.
Return the maximum tastiness of a candy basket.
Example 1
Input
price = [13,5,1,8,21,2], k = 3Output
8Choose candies with prices [13, 5, 21], whose pairwise absolute differences have minimum 8, and it can be proven that 8 is the maximum tastiness achievable.
Example 2
Input
price = [1,3,1], k = 2Output
2Choose candies with prices [1, 3], whose only absolute price difference is 2, and it can be proven that 2 is the maximum tastiness achievable.
Constraints
- 2 <= k <= price.length <= 10^5
- 1 <= price[i] <= 10^9