public class EasyCoverage { public static final int MIN = 1; public static final int MAX = 2; public static int MinMax(int [] ar, int flag) { if(ar.length==0) return 0; int m = ar[0]; for(int i=0; i<ar.length; i++) if(flag==MIN) { if(m > ar[i]) m = ar[i]; } else { if(m < ar[i]) m = ar[i]; } return m; } }