This is the program:
public class Program { public enum T { MIN, MAX } ; public static int mystery(int[] arr, int d, int f, T k ) { int a