Practice Maximum Tastiness of Candy Basket
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an array of positive integers price where price[i] denotes the price of the ith 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.
Source: Maximum Tastiness of Candy Basket on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
price = [13,5,1,8,21,2], k = 3
8
# Example 2
price = [1,3,1], k = 2
2
# Example 3
price = [7,7,7,7], k = 2
0
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Tastiness of Candy Basket.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.