Open Prajwal-Mohan opened 2 years ago
Goodies and Prices: Fitbit Plus: 7980 IPods: 22349 MI Band: 999 Cult Pass: 2799 Macbook Pro: 229900 Digital Camera: 11101 Alexa: 9999 Sandwich Toaster: 2195 Microwave Oven: 9800 Scale: 4999
Number of the employees: 4
Fitbit Plus: 7980 Microwave Oven: 9800 Alexa: 9999 Digital Camera: 11101 Sandwich Toaster: 2195 Cult Pass: 2799 Scale: 4999 Fitbit Plus: 7980 Microwave Oven: 9800 Alexa: 9999
import java.io.IOException; import java.util.Arrays; import java.util.Scanner;
public class Goodiss {
static int minDiff(int arr[], int n, int k) { int result = Integer.MAX_VALUE; Arrays.sort(arr); for (int i=0; i<= n-k;i++) result = Math.min(result, arr[i + k - 1] - arr[i]); return result;
} static int findele(int res,int arr[], int n, int k) { int result = Integer.MAX_VALUE; for(int i=0; i<=n; i++) { result = Math.min(result, arr[i + k - 1] - arr[i]); if (res==result) return i;
} public static void main(String[] args) throws IOException {
}
}