Company: Salesforce
Difficulty: medium
Maximum Value of Minimum Difference Problem Description Given an array of positive integers representing prices and a positive integer k, your task is to select a subset of k distinct elements from the array such that the difference between any two selected elements is minimized. Determine the maximum possible value of this minimum difference. Examples Example 1: Input: price = [13,5,1,8,21,2], k = 3 Output: 8 Explanation: Choose the subset with the prices [13,5,21]. Minimum value from this subset is: min(|13 - 5|, |13 - 21|, |5 - 21|) = min(8, 8, 16) = 8. It can be proven that 8 is the maximum possible value of this minimum difference that can be achieved. Example 2: Input: price = [1,3,1], k = 2 Output: 2 Explanation: Choose the subset with the prices [1,3]. Minimum value from this subset is: min(|1 - 3|) = min(2) = 2. It can be proven that 2 is the maximum possible value of this minimum difference that can be achieved. Example 3: Input: price = [7,7,7], k = 2